﻿chaplain_throw_move = {
	trigger_event = court_chaplain_finish.0001
}

chaplain_move = {
	scope:councillor_liege = {
		if = { # Convert capital
			limit = {
				capital_county ?= {
					de_jure_liege.holder = scope:councillor_liege
					potential_county_faith_conversion = yes
				}
			}
			scope:councillor = {
				set_council_task = {
					task_type = task_conversion
					target = prev.capital_province
				}
				save_temporary_scope_value_as = {
					name = councillor_on_work
					value = yes
				}
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:councillor_on_work }
			}
			random_directly_owned_province = { # Convert ruler province
				limit = {
					county = {
						potential_county_faith_conversion = yes
					}
				}
				scope:councillor = {
					set_council_task = {
						task_type = task_conversion
						target = prev
					}
					save_temporary_scope_value_as = {
						name = councillor_on_work
						value = yes
					}
				}
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:councillor_on_work }
			}
			random_vassal = { # Convert direct vassal
				limit = {
					highest_held_title_tier = tier_empire
					sub_realm_size > 1
					capital_county ?= {
						potential_county_faith_conversion = yes
					}
				}
				alternative_limit = {
					highest_held_title_tier = tier_kingdom
					sub_realm_size > 1
					capital_county ?= {
						potential_county_faith_conversion = yes
					}
				}
				alternative_limit = {
					highest_held_title_tier = tier_duchy
					sub_realm_size > 0
					capital_county ?= {
						potential_county_faith_conversion = yes
					}
				}
				alternative_limit = {
					highest_held_title_tier = tier_county
					sub_realm_size > 0
					capital_county ?= {
						potential_county_faith_conversion = yes
					}
				}	
				alternative_limit = {
					highest_held_title_tier = tier_barony
					capital_county ?= {
						potential_county_faith_conversion = yes
					}
				}
				scope:councillor = {
					set_council_task = {
						task_type = task_conversion
						target = prev.capital_province
					}					
					save_temporary_scope_value_as = {
						name = councillor_on_work
						value = yes
					}
				}
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:councillor_on_work }
			}
			random_vassal_or_below = { # Convert sub vassal
				limit = {
					highest_held_title_tier = tier_empire
					sub_realm_size > 1
					capital_county ?= {
						potential_county_faith_conversion = yes
					}
				}
				alternative_limit = {
					highest_held_title_tier = tier_kingdom
					sub_realm_size > 1
					capital_county ?= {
						potential_county_faith_conversion = yes
					}
				}
				alternative_limit = {
					highest_held_title_tier = tier_duchy
					sub_realm_size > 0
					capital_county ?= {
						potential_county_faith_conversion = yes
					}
				}			
				alternative_limit = {
					highest_held_title_tier = tier_county
					sub_realm_size > 0
					capital_county ?= {
						potential_county_faith_conversion = yes
					}
				}	
				alternative_limit = {
					highest_held_title_tier = tier_barony
					capital_county ?= {
						potential_county_faith_conversion = yes
					}
				}
				scope:councillor = {
					set_council_task = {
						task_type = task_conversion
						target = prev.capital_province
					}					
					save_temporary_scope_value_as = {
						name = councillor_on_work
						value = yes
					}
				}
			}
		}
		if = {
			limit = {
				NOT = { exists = scope:councillor_on_work }
			}
			random_sub_realm_county = { # Convert other province
				limit = {
					county = {
						has_faith_block_conversion_trigger = no
						potential_county_faith_conversion = yes
					}
				}
				alternative_limit = {
					county = {
						potential_county_faith_conversion = yes
					}
				}
				scope:councillor = {
					set_council_task = {
						task_type = task_conversion
						target = prev.title_capital_county.title_province
					}
					save_temporary_scope_value_as = {
						name = councillor_on_work
						value = yes
					}
				}
			}
		}
	}
}