﻿task_collect_taxes = {
	default_task = yes
	position = councillor_steward

	task_type = task_type_general
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_collect_taxes.dds"
		background = "gfx/interface/buttons/button_round_bg.dds"
		frame = "gfx/interface/buttons/button_round_frame.dds"
		glow = "gfx/particles/halo.dds"
	}

	effect_desc = {
		desc = task_collect_taxes_effect_desc
		triggered_desc = {
			trigger = { liege = { has_perk = tax_man_perk } }
			desc = task_collect_taxes_tax_man_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_collect_taxes_erudition_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_collect_taxes_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_collect_taxes_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = { liege.culture = { has_cultural_parameter = bookkeeping_collect_taxes_bonus } }
			desc = task_collect_taxes_innovation_double_entry_bookkeeping_bonus_desc
		}
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					stewardship > mediocre_skill_rating
				}
				desc = task_collect_taxes_extra_taxes
			}
			triggered_desc = {
				trigger = {
					stewardship < high_skill_rating
					liege = {
						any_sub_realm_county = {
							steward_task_county_corruption_county_trigger = yes
						}
					}	
				}
				desc = task_collect_taxes_county_corruption
			}
		}
	}

	is_valid_showing_failures_only = {
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	council_owner_modifier = {
		name = task_collect_taxes_modifier
		domain_tax_mult = 1
		scale = steward_collect_taxes_total_scale
	}

	monthly_on_action = task_collect_taxes_side_effects

	ai_will_do = {
		value = 1 # Always a good backup
		
		if = { # Very greedy rulers prefer this over increasing Acceptance, in most cases
			limit = {
				scope:councillor_liege.ai_greed > 0
			}
			add = {
				value = scope:councillor_liege.ai_greed
				divide = 5
			}
		}
		
		if = {
			# Wealth Focused characters like this
			limit = {
				scope:councillor_liege = {
					has_focus = stewardship_wealth_focus
				}
			}
			add = 15
		}
		
		if = {
			# And those with the Tax Man perk
			limit = {
				scope:councillor_liege = {
					has_perk = tax_man_perk
				}
			}
			add = 15
		}
		if = {
			limit = {
				scope:councillor_liege.primary_title.tier >= tier_duchy
				scope:councillor_liege.gold < 100
			}
			add = 500
		}
		else_if = {
			limit = {
				scope:councillor_liege.gold < 10
			}
			add = 500
		}
		if = { # Conquerors want more money
			limit = {
				scope:councillor_liege = {
					has_variable = conqueror
				}
			}
			add = 500
		}
	}
}

task_develop_county = {
	position = councillor_steward

	task_type = task_type_county
	county_target = realm
	ai_county_target = domain
	task_progress = task_progress_value
	task_current_value = scope:councillor_liege.steward_develop_county_current_progress
	task_max_value = 100
	highlight_own_realm = yes

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_develop_county.dds"
		background = "gfx/interface/buttons/button_round_bg.dds"
		frame = "gfx/interface/buttons/button_round_frame.dds"
		glow = "gfx/particles/halo.dds"
	}
	
	is_shown = {
		trigger_if = {
			limit = {
				scope:councillor_liege = { tgp_has_access_to_ministry_trigger = yes }
			}
			has_council_position = minister_works
		}
	}

	effect_desc = {
		desc = task_develop_county_complete_effect_desc
		desc = task_develop_county_effect_desc
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					stewardship > mediocre_skill_rating
					trigger_if = {
						limit = {
							exists = scope:county
						}
						scope:county = {
							NOT = { has_county_modifier = steward_task_efficient_taxation_modifier }
						}
					}
				}
				desc = task_develop_county_efficient_taxation
			}
			triggered_desc = {
				trigger = {
					stewardship > mediocre_skill_rating
					trigger_if = {
						limit = { exists = scope:county }
						scope:county = {
							county_control < full_county_control
						}
					}
				}
				desc = task_develop_county_increased_control
			}
			triggered_desc = {
				trigger = {
					stewardship < high_skill_rating
					trigger_if = {
						limit = { exists = scope:county }
						scope:county = {
							NOT = { has_county_modifier = steward_settler_resistance_modifier }
						}
					}
				}
				desc = task_develop_county_increased_control
			}
			triggered_desc = {
				trigger = {
					stewardship < high_skill_rating
					trigger_if = {
						limit = { exists = scope:county }
						scope:county = {
							NOT = { has_county_modifier = steward_construction_slowdown_modifier }
						}
					}
				}
				desc = task_develop_county_slow_construction
			}
			triggered_desc = {
				trigger = {
					stewardship < high_skill_rating
					trigger_if = {
						limit = { exists = scope:county }
						scope:county = {
							NOT = { has_county_modifier = steward_population_mismanaged_modifier }
						}
					}
				}
				desc = task_develop_county_loss_of_opinion
			}
			triggered_desc = {
				trigger = {
					stewardship < high_skill_rating
					trigger_if = {
						limit = { exists = scope:county }
						scope:county = {
							county_control > low_county_control
						}
					}
				}
				desc = task_develop_county_loss_of_control
			}
		}
	}

	is_valid_showing_failures_only = {
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	# TOTAL PROGRESS MUST MATCH THE TOTAL OF THE COUNTY MODIFIERS BELOW
		# Add all new progress values to the script value steward_develop_county_total
		# Note that for Develop County, the County Modifiers apply the actual values, while progress is for player info only
	progress = {
		value = 0
		add = {
			value = steward_develop_county_base
			desc = STEWARD_PROGRESS_BASE
		}
		add = {
			value = scope:councillor.steward_develop_county_monthly_increase
			desc = SCALED_COUNCILLOR_STEWARDSHIP_VALUE
		}
		if = {
			limit = {
				scope:councillor_liege = { has_perk = planned_cultivation_perk }
			}
			add = {
				value = scope:councillor.steward_develop_county_perk_bonus_monthly_increase
				desc = DEVELOP_COUNTY_PERK_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			add = {
				value = scope:councillor.steward_develop_county_erudition_bonus_monthly_increase
				desc = ERUDITION_DYNASTY_PERK_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_family_business_bonus = yes
			}
			add = {
				value = scope:councillor.steward_develop_county_family_business_monthly_increase
				desc = FAMILY_BUSINESS_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			add = {
				value = scope:councillor.steward_develop_county_consulted_house_monthly_increase
				desc = CONSULTED_HOUSE_BONUS_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.steward_develop_county_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.steward_develop_county_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.steward_develop_county_monthly_increase_rival_bonus
				desc = COUNCILLOR_IS_YOUR_RIVAL
			}
		}
		if = { # Nemesis
			limit = {
				scope:councillor_liege = {
					has_relation_nemesis = scope:councillor
				}
			}
			add = {
				value = scope:councillor.steward_develop_county_monthly_increase_nemesis_bonus
				desc = COUNCILLOR_IS_YOUR_NEMESIS
			}
		}
		if = { #Tribal penalty
			limit = {
				scope:councillor_liege = {
					should_apply_tribal_development_penalty_trigger = yes	
				}
			}
			add = {
				value = scope:councillor.steward_develop_county_tribal_penalty
				desc = DEVELOP_COUNTY_TRIBAL_PENALTY_VALUE
			}
		}	
		if = { # Development reduces the speed.
			limit = {
				exists = scope:county
				scope:county = {
					development_level > 0
				}
			}
			add = {
				value = scope:county.current_development_penalty
				desc = STEWARD_CURRENT_DEVELOPMENT_PENALTY
			}
		}
		
		if = {
			limit = { exists = scope:county }
			multiply = {
				value = scope:county.development_rate_modifier
				desc = STEWARD_COUNTY_SPEED_MODIFIERS
			}
		}

        # Royal Architect
        if = {
            limit = {
                scope:councillor_liege = { has_character_modifier = employer_booner_royal_architect_2_modifier }
                OR = {
                    target_is_vassal_or_below = scope:target_character
                    this = scope:target_character
                }
            }
            multiply = {
                value = 1.1
                desc = employer_booner_royal_architect_2_modifier
            }
        }
        else_if = {
            limit = {
                scope:councillor_liege = { has_character_modifier = employer_booner_royal_architect_3_modifier }
                OR = {
                    target_is_vassal_or_below = scope:target_character
                    this = scope:target_character
                }
            }
            multiply = {
                value = 1.1
                desc = employer_booner_royal_architect_3_modifier
            }
        }
	}
	full_progress = steward_develop_county_full_progress
	custom_other_loc = STEWARD_COUNTY_SPEED_OTHER

	potential_county = {
		scope:county = {
			is_landless_type_title = no
			development_level < max_development_level
			trigger_if = {
				limit = {
					scope:councillor_liege = {
						is_ai = yes
						exists = capital_county
					}
				}
				OR = {
					this = scope:councillor_liege.capital_county
					AND = {
						holder = scope:councillor_liege
						title_province = {
							OR = {
								terrain = oasis
								terrain = farmlands
								terrain = floodplains
							}
						}
					}
				}
				OR = {
					scope:councillor_liege = {
						has_character_flag = vassal_directive_improve_development
						vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
					}
					culture = scope:councillor_liege.culture
					culture = {
						cultural_acceptance = { target = scope:councillor_liege.culture value >= 50 }
					}
					scope:councillor_liege = {
						primary_title.tier < tier_duchy
					}
					AND = {
						scope:councillor_liege = {
							has_character_flag = agenda_towards_deescalation
						}
						culture != scope:councillor_liege.culture
					}
				}
			}
		}
	}

	county_modifier = {
		name = steward_develop_county_modifier
		development_growth = 100
		holding_build_speed = -7
		#holding_build_gold_cost = -1
		build_speed = -7
		#build_gold_cost = -1
		scale = { value = steward_develop_county_total divide = 100 }
	}

	county_modifier = {
		name = steward_develop_county_current_development_modifier
		development_growth = 100
		scale = { value = scope:councillor.current_development_penalty divide = 100 }
	}

	county_modifier = {
		name = steward_develop_county_tribal_penalty_modifier
		development_growth = 100
		scale = {
			value = 0
			if = {
				limit = {
					scope:councillor_liege = {
						should_apply_tribal_development_penalty_trigger = yes
					}
				}
				value = scope:councillor.steward_develop_county_tribal_penalty
				divide = 100
			}
		}
	}

	on_start_task_county = {
		# save current development_level for catalyst purpose
		if = {
			limit = { exists = scope:county }
			scope:county = {
				set_variable = {
					name = current_development_level
					value = development_level
				}
			}
		}
	}

	on_finish_task_county = {
		if = {
			limit = {
				OR = {
					AND = {
						exists = scope:county
						scope:county = {
							development_level = max_development_level
						}
					}
					scope:councillor_liege = {
						is_ai = yes
					}
				}
			}
			start_default_task = yes
		}
	}

	monthly_on_action = task_develop_county_side_effects

	on_monthly_county = {
		scope:councillor_liege = {
			# Check development level progress
			if = {
				limit = {
					exists = scope:county
					exists = scope:county.var:current_development_level
					scope:county = {
						floored_development_value > floored_current_development_value
					}
				}
				scope:county = {
					set_variable = {
						name = current_development_level
						value = development_level
					}
				}
				
				scope:councillor_liege = {
					if = { # Try to make relevant AI's focus on Acceptance
						limit = {
							exists = primary_title
							primary_title.tier >= tier_kingdom
							any_sub_realm_county = {
								culture = {
									cultural_acceptance = { target = scope:councillor_liege.culture value < 52 }
								}
							}
							NOT = {
								has_focus = stewardship_domain_focus
							}
						}
						add_character_flag = {
							flag = no_ai_increase_development
							years = 15
						}
					}
					else = {
						add_character_flag = {
							flag = no_ai_increase_development
							years = 5
						}
					}
				}
				
				# Struggle Catalyst
				if = {
					limit = {
						exists = scope:county
						# target someone from diff faith or culture
						scope:county = {
							NAND = {
								faith = scope:councillor_liege.faith
								culture = scope:councillor_liege.culture
							}
						}

						any_character_struggle = {
							involvement = involved
							phase_has_catalyst = catalyst_improve_development_vassal_diff_faith_culture
						}
					}
					scope:councillor_liege = {
						every_character_struggle = {
							involvement = involved
							activate_struggle_catalyst = {
								catalyst = catalyst_improve_development_vassal_diff_faith_culture
								character = scope:councillor_liege
							}
						}
					}
					# Struggle Parameter
					if = {
						limit = {
							scope:county.culture != scope:councillor_liege.culture
							any_character_struggle = {
								involvement = involved
								has_struggle_phase_parameter = gain_acceptance_when_developing_other_culture_county
							}
						}
						scope:county.culture = {
							save_scope_as = current_culture
							change_cultural_acceptance = {
								target = scope:councillor_liege.culture
								value =	miniscule_cultural_acceptance_value
								desc = cultural_acceptance_gain_from_phase_effects
							}
						}
					}

				}
			}
			else_if = { # fallback for previous save: the effect would trigger a month later
				limit = {
					exists = scope:county
				}
				scope:county = {
					set_variable = {
						name = current_development_level
						value = development_level
					}
				}
			}
		}
	}

	ai_will_do = {
		value = 0
		if = {
			limit = {
				scope:councillor = {
					is_performing_council_task = task_develop_county
				}
			}
			add = 10000 # Always keep going if this is already chosen
		}
		if = {
			# Don't do this too often
			limit = {
				scope:councillor_liege = { has_character_flag = no_ai_increase_development }
			}
			multiply = 0
		}
		else_if = {
			limit = {
				scope:councillor_liege.gold >= steward_increase_development_value
			}
			add = 300
		}
		if = {
			limit = {
				scope:councillor_liege.gold < 10
			}
			multiply = 0
		}
		
		# AI directive
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_flag = vassal_directive_improve_development
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			add = 50000
		}
	}
}

task_promote_culture = {
	position = councillor_steward

	task_type = task_type_county
	county_target = realm
	ai_county_target = realm
	task_progress = task_progress_percentage
	restart_on_finish = yes
	highlight_own_realm = yes

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_promote_culture.dds"
		background = "gfx/interface/buttons/button_round_bg.dds"
		frame = "gfx/interface/buttons/button_round_frame.dds"
		glow = "gfx/particles/halo.dds"
	}
	
	effect_desc = {
		desc = {
			desc = task_promote_culture_effect_desc
			triggered_desc = {
				trigger = {
					scope:councillor_liege = {
						any_vassal = {
							vassal_stance = minority
						}
					}
				}
				desc = minority_disapproves_conversion_tooltip
			}
			triggered_desc = {
				trigger = {
					trigger_if = {
						limit = { exists = scope:county }
						scope:county = {
							culture != scope:councillor_liege.culture
						}
						NOT = {
							scope:councillor_liege.culture = {
								is_hybrid_culture = yes
								any_parent_culture = {
									this = scope:county.culture
								}
							}
						}
					}
					trigger_else = { always = no }
				}
				desc = task_promote_culture_acceptance_effect_desc
			}
		}
		desc = {
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					stewardship > mediocre_skill_rating
					trigger_if = {
						limit = { exists = scope:county }
						scope:county = {
							NOT = { has_county_modifier = steward_task_efficient_taxation_modifier }
						}
					}
				}
				desc = task_promote_culture_improve_county_opinion
			}
			triggered_desc = {
				trigger = {
					stewardship > mediocre_skill_rating
					trigger_if = {
						limit = { exists = scope:county }
						scope:county = {
							NOT = { has_county_modifier = steward_task_efficient_taxation_modifier }
						}
					}
				}
				desc = task_promote_culture_increased_taxes
			}
			triggered_desc = {
				trigger = {
					stewardship > mediocre_skill_rating
					trigger_if = {
						limit = { exists = scope:county }
						scope:county = {
							NOT = { has_county_modifier = steward_task_efficient_taxation_modifier }
						}
					}
				}
				desc = task_promote_culture_increased_levies
			}
			triggered_desc = {
				trigger = {
					stewardship < high_skill_rating
					trigger_if = {
						limit = { exists = scope:county }
						scope:county = {
							NOT = { has_county_modifier = steward_settler_resistance_modifier }
						}
					}
				}
				desc = task_promote_culture_resistance_to_settlers
			}
			triggered_desc = {
				trigger = {
					stewardship < high_skill_rating
					trigger_if = {
						limit = { exists = scope:county }
						scope:county = {
							NOT = { has_county_modifier = steward_settler_resistance_modifier }
						}
					}
				}
				desc = task_promote_culture_resistance_to_administration
			}
		}
	}

	is_valid_showing_failures_only = {
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	progress = {
		value = 0
		add = {
			value = steward_promote_culture_base
			desc = STEWARD_PROGRESS_BASE
		}
		add = {
			value = scope:councillor.steward_promote_culture_monthly_increase
			desc = SCALED_COUNCILLOR_STEWARDSHIP_VALUE
		}

		add = steward_promote_culture_contextual_bonuses
		
		if = { # Development reduces the speed. Should be the last non-multiply modifier applied to avoid negative values
			limit = {
				exists = scope:county
				scope:county = {
					development_level > 0
				}
			}
			add = {
				value = scope:county.promote_culture_development_penalty
				desc = STEWARD_PROMOTE_CULTURE_DEVELOPMENT_PENALTY
			}
		}
		
		if = { # Development reduces the speed. Should be the last non-multiply modifier applied to avoid negative values
			limit = {
				exists = scope:county
				scope:county = {
					county_control <= 25
					county_control >= 0
				}
			}
			multiply = {
				value = 0.3
				desc = STEWARD_PROMOTE_CULTURE_LOW_CONTROL_PENALTY
			}
		}
		if = { # Development reduces the speed. Should be the last non-multiply modifier applied to avoid negative values
			limit = {
				exists = scope:county
				scope:county = {
					county_control <= 50
					county_control > 25
				}
			}
			multiply = {
				value = 0.5
				desc = STEWARD_PROMOTE_CULTURE_MEDIUM_CONTROL_PENALTY
			}
		}
		if = { # Development reduces the speed. Should be the last non-multiply modifier applied to avoid negative values
			limit = {
				exists = scope:county
				scope:county = {
					county_control <= 75
					county_control > 50
				}
			}
			multiply = {
				value = 0.7
				desc = STEWARD_PROMOTE_CULTURE_HIGH_CONTROL_PENALTY
			}
		}
		if = { # Development reduces the speed. Should be the last non-multiply modifier applied to avoid negative values
			limit = {
				exists = scope:county
				scope:county = {
					county_control <= 100
					county_control > 75
				}
			}
			multiply = {
				value = 1.2
				desc = STEWARD_PROMOTE_CULTURE_HIGH_CONTROL_BONUS
			}
		}
		if = { # Development reduces the speed. Should be the last non-multiply modifier applied to avoid negative values
			limit = {
				exists = scope:county
				scope:county = {
					county_control > 100
				}
			}
			multiply = {
				value = 1.5
				desc = STEWARD_PROMOTE_CULTURE_ABSOLUTE_CONTROL_BONUS
			}
		}
		#####
		if = { # Development reduces the speed. Should be the last non-multiply modifier applied to avoid negative values
			limit = {
				exists = scope:county.title_province
				scope:county.title_province = {
					OR = {
						terrain = jungle
						terrain = mountains
						terrain = desert
						terrain = desert_mountains
						terrain = taiga
						terrain = wetlands
					}
				}
			}
			multiply = {
				value = 0.4
				desc = STEWARD_PROMOTE_CULTURE_HIGH_TERRAIN_PENALTY
			}
		}
		if = { # Development reduces the speed. Should be the last non-multiply modifier applied to avoid negative values
			limit = {
				exists = scope:county.title_province
				scope:county.title_province = {
					OR = {
						terrain = floodplains
						terrain = drylands
						terrain = steppe
						terrain = forest
						terrain = hills
						terrain = tells
					}
				}
			}
			multiply = {
				value = 0.5
				desc = STEWARD_PROMOTE_CULTURE_LOW_TERRAIN_PENALTY
			}
		}
		# Conversion speed game rules
		if = {
			limit = {
				has_game_rule = slower_culture_conversion_speed
			}
			multiply = {
				value = slower_game_rule_value
				desc = GAME_RULE_SLOWER_REASON
			}
		}
		if = {
			limit = {
				has_game_rule = significantly_slower_culture_conversion_speed
			}
			multiply = {
				value = significantly_slower_game_rule_value
				desc = GAME_RULE_SIGNIFICANTLY_SLOWER_REASON
			}
		}
		if = {
			limit = {
				has_game_rule = significantly_faster_culture_conversion_speed
			}
			multiply = {
				value = significantly_faster_game_rule_value
				desc = GAME_RULE_SIGNIFICANTLY_FASTER_REASON
			}
		}
		if = {
			limit = {
				has_game_rule = faster_culture_conversion_speed
			}
			multiply = {
				value = faster_game_rule_value
				desc = GAME_RULE_FASTER_REASON
			}
		}
		# Faster conversion for FP2 Hostility ending, if county is in Iberia and culture was involved
		if = {
			limit = {
				any_in_global_list = {
					variable = fp2_struggle_ending_culture_list
					this = scope:county.culture
				}
				scope:county.title_province = { geographical_region = world_europe_west_iberia }
				scope:councillor.liege.house = {
					OR = {
						has_house_modifier = fp2_struggle_hostility_house_culture_modifier
						has_house_modifier = fp2_struggle_hostility_house_combined_modifier
					}
				}
			}
			multiply = {
				value = fp2_struggle_hostility_conversion_value
				desc = fp2_struggle_hostility_culture_conversion_task_desc
			}
		}
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_modifier = devoted_to_tradition_modifier
				}
			}
			multiply = {
				value = 1.25
				desc = bp2_devoted_to_tradition_modifier_conversion_task_desc
			}
		}
		if = {
			limit = {
				scope:councillor_liege = {
					has_title = title:c_byzantion
					title:c_byzantion = { has_county_modifier = pandidakterion_university_modifier }
				}
			}
			multiply = {
				value = 1.25
				desc = pandidakterion_university_modifier
			}
		}
		if = {
			limit = {
				scope:county = { has_county_modifier = improve_promote_culture_modifier }
				scope:councillor_liege = scope:county.holder.top_liege
			}
			multiply = {
				value = 1.20
				desc = improve_promote_culture_modifier
			}
		}
	}

	potential_county = {
		scope:county = {
			is_landless_type_title = no
			culture != scope:councillor_liege.culture
			trigger_if = {
				limit = {
					scope:councillor_liege = { has_variable = hold_court_8130_culture_block }
				}
				custom_tooltip = {
					text = hold_court_8130_conversion_tt
					culture != scope:councillor_liege.var:hold_court_8130_culture_block
				}
			}
		}
		trigger_if = {
			limit = {
				scope:councillor_liege = {
					is_ai = yes
					NAND = { # AI Directives override this
						has_character_flag = vassal_directive_convert_culture
						vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
					}
				}
			}
			NAND = { # Princes in the HRE tend to not convert each other's cultures
				exists = title:e_hre.holder
				scope:councillor_liege.top_liege = title:e_hre.holder
				OR = {
					scope:councillor_liege.culture = culture:czech
					scope:councillor_liege.culture = { has_cultural_pillar = heritage_central_germanic }
				}
				OR = {
					scope:county.culture = culture:czech
					scope:county.culture = { has_cultural_pillar = heritage_central_germanic }
				}
			}
			NOT = { # Do not eliminate the Basques
				scope:county.culture = {
					this = culture:basque
					any_culture_county = {
						count <= 5
					}
				}
			}
			scope:councillor_liege = {
				OR = {
					NOT = {
						scope:county.culture = {
							cultural_acceptance = { target = scope:councillor_liege.culture value >= 50 }
						}
					}
					scope:county = {
						this = title:c_maragha
						culture = culture:turkish
					}
					culture = { # All AI's are motivated to spread new Hybrid/Divergent cultures
						OR = {
							is_hybrid_culture = yes
							is_divergent_culture = yes
						}
						NOT = { # Leave the Welsh alone!
							this = culture:anglo_saxon
						}
						any_parent_culture = {
							this = scope:county.culture
						}
					}
					culture = { # Small cultures want to grow a bit
						any_culture_county = {
							count < 10
						}
					}
					scope:county.culture = { # 'dead' small cultures can go away
						OR = {
							is_hybrid_culture = yes
							is_divergent_culture = yes
						}
						any_culture_county = {
							count < 10
						}
						OR = {
							NOT = { exists = culture_head }
							any_culture_county = {
								count < 5
							}
						}
					}
					AND = {
						# Scottish rulers should convert counties of 'old' cultures to the new one.
						culture = culture:scottish
						OR = {
							scope:county.culture = culture:anglo_saxon
							scope:county.culture = culture:gaelic
							scope:county.culture = culture:cumbrian
							scope:county.culture = culture:pictish
						}
					}
					AND = {
						# English rulers should convert counties of 'old' cultures to the new one.
						culture = culture:english
						OR = {
							scope:county.culture = culture:anglo_saxon
							scope:county.culture = culture:norman
						}
					}
					AND = {
						# German rulers want to convert the polabians
						culture = { has_cultural_pillar = heritage_central_germanic }
						scope:county.culture = culture:polabian
						NOT = { scope:councillor_liege.primary_title = title:e_hre }
					}

					AND = {
						# Japanese rulers should convert Emishi counties
						culture = culture:japanese
						scope:county.culture = culture:emishi
					}
				}
				OR = {
					is_independent_ruler = yes
					primary_title.tier > tier_county
					culture = { # All AI's are motivated to spread new Hybrid/Divergent cultures
						OR = {
							is_hybrid_culture = yes
							is_divergent_culture = yes
						}
						any_parent_culture = {
							this = scope:county.culture
						}
					}
					culture = { # Small cultures want to grow a bit
						any_culture_county = {
							count < 10
						}
					}
					scope:county.culture = { # 'dead' small cultures can go away
						OR = {
							is_hybrid_culture = yes
							is_divergent_culture = yes
						}
						any_culture_county = {
							count < 10
						}
						OR = {
							NOT = { exists = culture_head }
							any_culture_county = {
								count < 5
							}
						}
					}
					culture = { # Imperious cultures want to grow to a certain size
						culture_head ?= {
							is_independent_ruler = yes
							highest_held_title_tier >= tier_kingdom
							sub_realm_size >= 30
						}
						any_culture_county = {
							count < 35
						}
					}
					AND = {
						# Scottish rulers should convert counties of 'old' cultures to the new one.
						culture = culture:scottish
						OR = {
							scope:county.culture = culture:anglo_saxon
							scope:county.culture = culture:gaelic
							scope:county.culture = culture:cumbrian
							scope:county.culture = culture:pictish
						}
					}
					AND = {
						# English rulers should convert counties of 'old' cultures to the new one.
						culture = culture:english
						OR = {
							scope:county.culture = culture:anglo_saxon
							scope:county.culture = culture:norman
						}
					}
					AND = {
						# German rulers want to convert the polabians
						culture = { has_cultural_pillar = heritage_central_germanic }
						scope:county.culture = culture:polabian
						NOT = { scope:councillor_liege.primary_title = title:e_hre }
					}
					AND = {
						# Japanese rulers should convert Emishi counties
						culture = culture:japanese
						scope:county.culture = culture:emishi
					}
				}
			}
			OR = {
				scope:county = {
					any_neighboring_county = {
						culture = scope:councillor_liege.culture # The AI only wants to convert counties bordering their own culture
					}
				}
				AND = { # The English want to convert the Anglo Saxons and Cumbrians
					scope:councillor_liege.culture = culture:english
					OR = {
						scope:county.culture = culture:anglo_saxon
						scope:county.culture = culture:cumbrian
					}
				}
				AND = { # The Scots want to convert the Anglo Saxons, Cumbrians and Gaelic
					scope:councillor_liege.culture = culture:scottish
					OR = {
						scope:county.culture = culture:anglo_saxon
						scope:county.culture = culture:gaelic
						scope:county.culture = culture:cumbrian
						scope:county.culture = culture:pictish
					}
				}
				AND = { # The Gaels want to convert the Picts and Cumbrians
					scope:councillor_liege.culture = culture:gaelic
					OR = {
						scope:county.culture = culture:cumbrian
						scope:county.culture = culture:pictish
					}
				}
				AND = { # The modern scandinavians want to convert the Norse
					OR = {
						scope:councillor_liege.culture = culture:swedish
						scope:councillor_liege.culture = culture:danish
						scope:councillor_liege.culture = culture:norwegian
					}
					scope:county.culture = culture:norse
				}
				AND = { # The Portuguese should want to convert Suebi
					scope:councillor_liege.culture = culture:portuguese
					scope:county.culture = culture:suebi
				}
				AND = { # The Iberians want to convert Visigothic
					scope:councillor_liege.culture = { has_cultural_pillar = heritage_iberian }
					NOT = { scope:councillor_liege.culture = culture:portuguese }
					scope:county.culture = culture:visigothic
				}
				AND = {
					# German rulers want to convert the polabians
					scope:councillor_liege.culture = { has_cultural_pillar = heritage_central_germanic }
					scope:county.culture = culture:polabian
					NOT = { scope:councillor_liege.primary_title = title:e_hre }
				}
				AND = {
					# Japanese rulers should convert Emishi counties
					scope:councillor_liege.culture = culture:japanese
					scope:county.culture = culture:emishi
				}
			}
		}
		trigger_else_if = { # But AI Directives should still try to look pretty
			limit = {
				scope:councillor_liege = {
					is_ai = yes
					has_character_flag = vassal_directive_convert_culture
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			trigger_if = {
				limit = {
					scope:county = {
						any_neighboring_county = {
							culture = scope:councillor_liege.culture
						}
					}
				}
				scope:county = {
					any_neighboring_county = {
						culture = scope:councillor_liege.culture # The AI only wants to convert counties bordering their own culture
					}
				}
			}
			trigger_else = {
				always = yes
			}
		}
		trigger_else = {
		}
	}

	on_finish_task_county = {
		scope:councillor_liege = {
			if = {
				limit = {	
					NOT = {
						culture = {
							is_hybrid_culture = yes
							any_parent_culture = {
								this = scope:county.culture
							}
						}
					}
				}
				if = {
					limit = {
						top_liege != this
					}
					add_character_flag = {
						flag = no_ai_culture_convert
						years = 60
					}
				}
				else = {
					add_character_flag = {
						flag = no_ai_culture_convert
						years = 30
					}
				}
			}
		}
		scope:county = {
			if = {
				limit = {
					NOT = {
						scope:councillor_liege.culture = {
							is_hybrid_culture = yes
							any_parent_culture = {
								this = scope:county.culture
							}
						}
					}
				}
				culture = {
					change_cultural_acceptance = {
						target = scope:councillor_liege.culture
						value = culture_conversion_acceptance_impact
						desc = cultural_acceptance_loss_promote_culture
					}
				}
			}
			set_county_culture = scope:councillor_liege.culture
		}
		scope:councillor = {
			start_default_task = yes
		}
	}

	monthly_on_action = task_promote_culture_side_effects

	ai_will_do = {
		value = 0
		if = {
			limit = {
				scope:councillor = {
					is_performing_council_task = task_promote_culture
				}
			}
			add = 10000 # Always keep going if this is already chosen
		}
		else_if = {
			limit = {
				scope:councillor_liege = {
					gold > 0
					OR = {
						gold >= steward_convert_culture_value
						AND = {
							culture = culture:scottish
							top_liege.primary_title = title:k_scotland
							capital_county.kingdom = title:k_scotland
						}
						AND = {
							culture = culture:english
							top_liege.primary_title = title:k_england
							capital_county.kingdom = title:k_england
						}
						AND = {
							culture = { has_cultural_pillar = heritage_central_germanic }
							top_liege.primary_title = title:e_hre
							OR = {
								capital_county.kingdom = title:k_sorbia
								capital_county.kingdom = title:k_east_francia
								capital_county.kingdom = title:k_saxony
								capital_county.kingdom = title:k_pomerania
							}
						}
						AND = {
							culture = culture:japanese
							capital_county.empire = title:e_japan
						}
						AND = {
							culture = {
								OR = {
									is_hybrid_culture = yes
									is_divergent_culture = yes
								}
							}
							any_realm_county = {
								culture = {
									save_temporary_scope_as = culture_check
									scope:councillor_liege.culture = {
										any_parent_culture = {
											this = scope:culture_check
										}
									}
								}
							}
						}
						culture = { # Small cultures want to grow a bit
							any_culture_county = {
								count < 10
							}
						}
						culture = { # Imperious cultures want to grow to a certain size
							culture_head ?= {
								is_independent_ruler = yes
								highest_held_title_tier >= tier_kingdom
								sub_realm_size >= 30
							}
							NOR = {
								has_cultural_pillar = ethos_egalitarian
								has_cultural_tradition = tradition_xenophilic
							}
							any_culture_county = {
								count < 35
							}
						}
					}
				}
			}
			add = 500
		}
		if = {
			limit = {
				scope:councillor_liege.culture = {
					has_cultural_parameter = less_likely_to_promote_culture
				}
			}
			add = -250
		}
		if = {
			limit = {
				scope:councillor_liege = {
					culture = {
						OR = {
							is_hybrid_culture = yes
							is_divergent_culture = yes
						}
					}
					any_sub_realm_county = {
						culture = {
							save_temporary_scope_as = culture_check
							scope:councillor_liege.culture = {
								any_parent_culture = {
									this = scope:culture_check
								}
							}
						}
					}
				}
			}
			add = 200
		}
		# Motivate the AI with an escalation agenda to take this task
		if = {
			limit = {
				has_character_flag = agenda_towards_escalation
			}
			add = 500
		}
		else_if = {
			limit = {
				has_character_flag = agenda_towards_deescalation
			}
			add = -250
		}
		if = {
			# Don't do this too often
			limit = {
				scope:councillor_liege = {
					has_character_flag = no_ai_culture_convert
					NAND = { # ignore it if in Hostility with escalation
						has_character_flag = agenda_towards_escalation
						any_character_struggle = {
							involvement = involved
							is_struggle_type = iberian_struggle
							is_struggle_phase = struggle_iberia_phase_hostility
						}
					}
				}
			}
			multiply = 0
		}
		if = {
			# Interrupt this task if you're bankrupt
			limit = {
				scope:councillor_liege = {
					gold < -50
				}
			}
			multiply = 0
		}
		
		# AI directive
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_flag = vassal_directive_convert_culture
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			add = 50000
		}
	}
}

# This task is referenced from code so as to hook into the culture acceptance gain
# Its progress rate will be applied between the owner's culture and the culture of the county
task_accept_culture = {
	position = councillor_steward

	task_type = task_type_county
	county_target = realm
	ai_county_target = realm
	highlight_own_realm = yes
	task_progress = task_progress_infinite

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_accept_culture.dds"
		background = "gfx/interface/buttons/button_round_bg.dds"
		frame = "gfx/interface/buttons/button_round_frame.dds"
		glow = "gfx/particles/halo.dds"
	}

	effect_desc = {
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:province }
				desc = task_accept_culture_desc
			}
			desc = task_accept_culture_base_desc
		}
		desc = task_accept_culture_base_value_desc
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					top_liege = this
				}
			}
			desc = task_accept_culture_independent_desc
		}
		triggered_desc = {
			trigger = {
				scope:councillor_liege = {
					has_royal_court = yes
					has_dlc_feature = royal_court
					has_court_type = court_administrative
					court_grandeur_current_level >= 4
				}
			}
			desc = task_accept_culture_court_type_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_customs_legacy_perk = yes
			}
			desc = task_accept_culture_customs_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			desc = task_accept_culture_erudition_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_family_business_bonus = yes
			}
			desc = task_accept_culture_family_business_bonus_desc
		}
		triggered_desc = {
			trigger = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			desc = task_accept_culture_consulted_house_bonus_desc
		}
		triggered_desc = {
			trigger = {
				exists = scope:county
				culture = scope:county.culture
			}
			desc = task_accept_culture_same_culture_desc
		}
		desc = task_accept_culture_other_desc
		desc = council_task_possible_side_effects
		triggered_desc = {
			trigger = {
				stewardship > mediocre_skill_rating

			}
			desc = task_accept_culture_loss_of_control
		}
		triggered_desc = {
			trigger = {
				stewardship > mediocre_skill_rating
				trigger_if = {
					limit = {
						exists = scope:county
					}
					scope:county = {
						NOT = { has_county_modifier = steward_accept_culture_reduced_taxes_modifier }
					}
				}
			}
			desc = task_accept_culture_reduced_tax_income
		}
		triggered_desc = {
			trigger = {
				stewardship < high_skill_rating
				trigger_if = {
					limit = { exists = scope:county }
					scope:county = {
						NOR = {
							has_county_modifier = steward_accept_culture_reduced_development_spread_modifier
							has_county_modifier = steward_accept_culture_increased_development_spread_modifier
						}
					}
				}
			}
			desc = task_accept_culture_reduced_development_growth
		}
		triggered_desc = {
			trigger = {
				stewardship > average_skill_rating
				trigger_if = {
					limit = { exists = scope:county }
					scope:county = {
						NOR = {
							has_county_modifier = steward_accept_culture_reduced_development_spread_modifier
							has_county_modifier = steward_accept_culture_increased_development_spread_modifier
						}
					}
				}
			}
			desc = task_accept_culture_increased_development_growth
		}
		triggered_desc = {
			trigger = {
				stewardship > average_skill_rating
				trigger_if = {
					limit = { exists = scope:county }
					scope:county = {
						NOT = { has_county_modifier = steward_accept_culture_increased_opinion_modifier }
					}
				}
			}
			desc = task_accept_culture_increased_opinion
		}
		triggered_desc = {
			trigger = {
				stewardship > average_skill_rating
			}
			desc = task_accept_culture_acceptance_boost
		}
	}
	
	is_valid_showing_failures_only = {
		scope:councillor_liege = {
			highest_held_title_tier >= tier_duchy
		}
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	progress = {
		value = 0
		add = {
			value = task_accept_culture_base_progress
			desc = STEWARD_PROGRESS_BASE
		}
		add = {
			value = scope:councillor.steward_accept_culture_yearly_increase
			desc = SCALED_COUNCILLOR_STEWARDSHIP_VALUE
		}
		
		if = {
			limit = {
				scope:councillor.culture = scope:county.culture
			}
			add = {
				value = scope:councillor.steward_accept_culture_yearly_increase_same_culture_bonus
				desc = COUNCILLOR_SAME_CULTURE_AS_TARGET
			}
		}
		
		if = {
			limit = {
				councillor_liege_has_customs_legacy_perk = yes
			}
			add = {
				value = scope:councillor.steward_accept_culture_customs_bonus_yearly_increase
				desc = CUSTOMS_DYNASTY_PERK_BONUS_VALUE
			}
		}
		
		if = {
			limit = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			add = {
				value = scope:councillor.steward_accept_culture_erudition_bonus_yearly_increase
				desc = ERUDITION_DYNASTY_PERK_BONUS_VALUE
			}
		}

		if = {
			limit = {
				councillor_liege_has_family_business_bonus = yes
			}
			add = {
				value = scope:councillor.steward_promote_culture_family_business_bonus
				desc = FAMILY_BUSINESS_BONUS_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.steward_accept_culture_yearly_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.steward_accept_culture_yearly_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.steward_accept_culture_yearly_increase_rival_bonus
				desc = COUNCILLOR_IS_YOUR_RIVAL
			}
		}
		if = { # Nemesis
			limit = {
				scope:councillor_liege = {
					has_relation_nemesis = scope:councillor
				}
			}
			add = {
				value = scope:councillor.steward_accept_culture_yearly_increase_nemesis_bonus
				desc = COUNCILLOR_IS_YOUR_NEMESIS
			}
		}
		if = { # Independent Ruler
			limit = {
				scope:councillor_liege = {
					top_liege = this
				}
			}
			add = {
				value = steward_accept_culture_yearly_increase_independent_bonus
				desc = COUNCILLOR_LIEGE_IS_INDEPENDENT
			}
		}
		
		if = { # Court Type bonus
			limit = {
				scope:councillor_liege = {
					has_royal_court = yes
					has_dlc_feature = royal_court
					has_court_type = court_administrative
					court_grandeur_current_level >= 4
				}
			}
			add = {
				value = steward_accept_culture_court_type_bonus
				desc = COUNCILLOR_LIEGE_HAS_COURT_TYPE_BONUS
			}
		}

		if = { # Wayfarer Bonus 
			limit = {
				liege = { has_perk = of_the_people_perk }
			}
			multiply = 1.3
		}
	}
	
	potential_county = {
		scope:county = {
			is_landless_type_title = no
			culture != scope:councillor_liege.culture
			NOT = {
				culture = {
					cultural_acceptance = { target = scope:councillor_liege.culture value >= 100 }
				}
			}
			trigger_if = {
				limit = {
					scope:councillor_liege = { is_ai = yes }
				}
				NAND = {
					# Scottish rulers should convert counties of 'old' cultures to the new one.
					scope:councillor_liege.culture = culture:scottish
					OR = {
						scope:county.culture = culture:anglo_saxon
						scope:county.culture = culture:gaelic
						scope:county.culture = culture:cumbrian
						scope:county.culture = culture:pictish
					}
				}
				NAND = {
					# English rulers should convert counties of 'old' cultures to the new one.
					scope:councillor_liege.culture = culture:english
					OR = {
						scope:county.culture = culture:anglo_saxon
						scope:county.culture = culture:norman
					}
				}
				NAND = {
					# German rulers want to convert the polabians
					scope:councillor_liege.culture = { has_cultural_pillar = heritage_central_germanic }
					scope:county.culture = culture:polabian
					NOT = { scope:councillor_liege.primary_title = title:e_hre }
				}
				NAND = {
					# Japanese rulers should convert Emishi counties
					scope:councillor_liege.culture = culture:japanese
					scope:county.culture = culture:emishi
				}
				OR = {
					scope:councillor_liege = {
						has_character_flag = vassal_directive_improve_cultural_acceptance
						vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
					}
					this = scope:councillor_liege.capital_county
					scope:councillor_liege.capital_county = {
						OR = {
							culture = scope:councillor_liege.culture
							culture = {
								cultural_acceptance = { target = scope:councillor_liege.culture value >= 50 }
							}
						}
					}
				}
			}
		}
	}

	monthly_on_action = task_accept_culture_side_effects
	
	ai_will_do = {
		value = 1
		
		if = {
			# Prefer this over Collecting Taxes if you have some money
			limit = {
				scope:councillor_liege.gold >= steward_increase_development_value
			}
			add = 1
		}
		
		if = {
			# Compassionate rulers like doing this
			limit = {
				scope:councillor_liege.ai_compassion > 0
			}
			add = {
				value = scope:councillor_liege.ai_compassion
				divide = 5
			}
		}
		
		if = {
			# And those with the Open Minded perk
			limit = {
				scope:councillor_liege = {
					has_perk = open_minded_perk
				}
			}
			add = 15
		}
		
		if = {
			# And the norse!
			limit = {
				scope:councillor_liege = {
					culture = culture:norse
				}
			}
			add = 15
		}
		
		if = {
			# Rulers with a capital culture that isn't particularly accepted like this if they have some more counties in their realm of the culture
			limit = {
				scope:councillor_liege = {
					capital_county ?= {
						save_temporary_scope_as = county_check
						NOR = {
							culture = scope:councillor_liege.culture
							scope:councillor_liege.culture = {
								OR = {
									is_hybrid_culture = yes
									is_divergent_culture = yes
								}
								any_parent_culture = {
									this = scope:county_check.culture
								}
							}
							culture = {
								cultural_acceptance = { target = scope:councillor_liege.culture value >= 50 }
							}
						}
					}
					any_sub_realm_county = {
						count >= 3
						culture = scope:councillor_liege.capital_county.culture
					}
				}
			}
			add = 300
		}
		
		if = {
			# More likely for independent rulers
			limit = {
				scope:councillor_liege = {
					top_liege = this
				}
			}
			multiply = 2
		}
		if = {
			# More likely for xenophiles
			limit = {
				scope:councillor_liege = {
					culture = {
						OR = {
							has_cultural_tradition = tradition_xenophilic
							has_cultural_tradition = tradition_fp2_malleable_subjects
						}
					}
				}
			}
			multiply = 2
		}
		if = {
			# Interrupt this task if you're bankrupt
			limit = {
				scope:councillor_liege = {
					gold < -50
				}
			}
			multiply = 0
		}
		
		# AI directive
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_flag = vassal_directive_improve_cultural_acceptance
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
			add = 50000
		}
	}
}

task_convince_dejure = {
	position = councillor_steward

	task_type = task_type_county
	county_target = neighbor_land
	ai_county_target = neighbor_land
	task_progress = task_progress_percentage

	asset = {
		icon = "gfx/interface/icons/council_task_types/task_convince_dejure.dds"
		background = "gfx/interface/buttons/button_round_bg.dds"
		frame = "gfx/interface/buttons/button_round_frame.dds"
		glow = "gfx/particles/halo.dds"
	}

	effect_desc = {
		desc = {
			desc = task_convince_dejure_effect_desc
			desc = council_task_possible_side_effects
			triggered_desc = {
				trigger = {
					stewardship > mediocre_skill_rating
				}
				desc = task_convince_dejure_gain_prestige
			}
			triggered_desc = {
				trigger = {
					stewardship < high_skill_rating
				}
				desc = task_convince_dejure_lose_prestige
			}
			triggered_desc = {
				trigger = {
					stewardship < high_skill_rating
				}
				desc = task_convince_dejure_diplomatic_blunder
			}
		}
	}

	is_shown = {
		has_dlc_feature = royal_court
	}

	progress = {
		value = 0
		add = {
			value = steward_convince_dejure_base
			desc = STEWARD_PROGRESS_BASE
		}
		add = {
			value = scope:councillor.steward_convince_dejure_monthly_increase
			desc = SCALED_COUNCILLOR_STEWARDSHIP_VALUE
		}
		#CGV bonuses/maluses
		if = {
			limit = {
				scope:councillor_liege = {
					court_grandeur_current_level = 7
				}
			}
			add = {
				value = 0.1
				desc = steward_convince_dejure_cg_bonus_desc
			}
		}
		if = {
			limit = {
				scope:councillor_liege = {
					court_grandeur_current_level = 8
				}
			}
			add = {
				value = 0.2
				desc = steward_convince_dejure_cg_bonus_desc
			}
		}
		if = {
			limit = {
				scope:councillor_liege = {
					court_grandeur_current_level = 9
				}
			}
			add = {
				value = 0.3
				desc = steward_convince_dejure_cg_bonus_desc
			}
		}
		if = {
			limit = {
				scope:councillor_liege = {
					court_grandeur_current_level = 10
				}
			}
			add = {
				value = 0.4
				desc = steward_convince_dejure_cg_bonus_desc
			}
		}
		if = {
			limit = {
				scope:county.holder.top_liege = {
					court_grandeur_current_level = 7
				}
			}
			add = {
				value = -0.1
				desc = steward_convince_dejure_cg_malus_desc
			}
		}
		if = {
			limit = {
				scope:county.holder.top_liege = {
					court_grandeur_current_level = 8
				}
			}
			add = {
				value = -0.2
				desc = steward_convince_dejure_cg_malus_desc
			}
		}
		if = {
			limit = {
				scope:county.holder.top_liege = {
					court_grandeur_current_level = 9
				}
			}
			add = {
				value = -0.3
				desc = steward_convince_dejure_cg_malus_desc
			}
		}
		if = {
			limit = {
				scope:county.holder.top_liege = {
					court_grandeur_current_level = 10
				}
			}
			add = {
				value = -0.4
				desc = steward_convince_dejure_cg_malus_desc
			}
		}
		# 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.steward_convince_dejure_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.steward_convince_dejure_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.steward_convince_dejure_monthly_increase_rival_bonus
				desc = COUNCILLOR_IS_YOUR_RIVAL
			}
		}
		if = { # Nemesis
			limit = {
				scope:councillor_liege = {
					has_relation_nemesis = scope:councillor
				}
			}
			add = {
				value = scope:councillor.steward_convince_dejure_monthly_increase_nemesis_bonus
				desc = COUNCILLOR_IS_YOUR_NEMESIS
			}
		}
		if = {
			limit = {
				councillor_liege_has_erudition_legacy_5_perk = yes
			}
			add = {
				value = steward_convince_dejure_erudition_bonus
				desc = ERUDITION_DYNASTY_PERK_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_family_business_bonus = yes
			}
			add = {
				value = steward_convince_dejure_family_business_bonus
				desc = FAMILY_BUSINESS_BONUS_VALUE
			}
		}
		if = {
			limit = {
				councillor_liege_has_consulted_house_bonus = yes
			}
			add = {
				value = steward_convince_dejure_consulted_house_bonus
				desc = CONSULTED_HOUSE_BONUS_VALUE
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:councillor_liege = {
			#Unlocked at Court Grandeur level 6
			court_grandeur_current_level >= 6
		}
		tgp_natural_disaster_councillor_available_for_task_trigger = yes
	}

	potential_county = {
		scope:county = { is_landless_type_title = no }
		custom_tooltip = {
			text = steward_convince_dejure_potential_county_tt
			scope:councillor_liege = {
				any_held_title = {
					any_in_de_jure_hierarchy = {
						tier = tier_county
						NOT = {
							has_county_modifier = steward_de_jure_denied_modifier
						}
						this = scope:county
						holder = {
							NOT = {
								target_is_liege_or_above = scope:councillor_liege
							}
						}
					}
				}
			}
		}
		custom_tooltip = steward_convince_dejure_potential_county_tt_2
		trigger_if = {
			limit = {
				scope:councillor_liege = { is_ai = yes }
			}
			OR = {
				top_liege = this
				scope:councillor_liege.primary_title.tier > tier_county
			}
			scope:county = {
				any_neighboring_county = {
					holder.top_liege = scope:councillor_liege # The AI only wants to convince counties bordering their own land
				}
			}
		}
	}

	on_finish_task_county = {
		scope:councillor = {
			start_default_task = yes
		}
		scope:councillor_liege = {
			if = {
				limit = {
					top_liege != this
				}
				add_character_flag = {
					flag = no_de_jure_convince
					years = 50
				}
			}
			else = {
				add_character_flag = {
					flag = no_de_jure_convince
					years = 20
				}
			}
		}
		scope:county.holder.top_liege = {
			trigger_event = steward_task.0001
		}
	}

	monthly_on_action = task_convince_dejure_side_effects
	
	ai_will_do = {
		value = 0
		if = {
			limit = {
				scope:councillor = {
					is_performing_council_task = task_convince_dejure
				}
			}
			add = 10000 # Always keep going if this is already chosen
		}
		# increase likelyhood with court grandeur level
		if = {
			limit = {
				scope:councillor_liege = {
					has_character_modifier = court_grandeur_level_6
				}
			}
			add = 100
		}
		else_if = {
			limit = {
				scope:councillor_liege = {
					has_character_modifier = court_grandeur_level_7
				}
			}
			add = 150
		}
		else_if = {
			limit = {
				scope:councillor_liege = {
					has_character_modifier = court_grandeur_level_8
				}
			}
			add = 200
		}
		else_if = {
			limit = {
				scope:councillor_liege = {
					has_character_modifier = court_grandeur_level_9
				}
			}
			add = 250
		}
		else_if = {
			limit = {
				scope:councillor_liege = {
					has_character_modifier = court_grandeur_level_10
				}
			}
			add = 300
		}
		if = {
			# Don't do this too often
			limit = {
				scope:councillor_liege = { has_character_flag = no_de_jure_convince }
			}
			multiply = 0
		}
	}
}
