﻿marshal_throw_move = {
	trigger_event = marshal_finish.0001
}

marshal_move = {
	scope:councillor_liege = {
		if = { # Secure capital
			limit = {
				capital_county ?= {
					de_jure_liege.holder = scope:councillor_liege
					is_potential_control_county_trigger = yes
				}				
			}
			scope:councillor = {
				set_council_task = {
					task_type = task_increase_control
					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 = { # Secure ruler province
				limit = {
					county = {
						is_potential_control_county_trigger = yes
					}
				}
				scope:councillor = {
					set_council_task = {
						task_type = task_increase_control
						target = prev
					}
					save_temporary_scope_value_as = {
						name = councillor_on_work
						value = yes
					}
				}
			}
		}		
		if = {
			limit = {
				NOT = { exists = scope:councillor_on_work }
			}
			random_vassal = { # Secure direct vassal
				limit = {
					highest_held_title_tier = tier_empire
					sub_realm_size > 1
					capital_county ?= {
						is_potential_control_county_trigger = yes
					}
				}			
				alternative_limit = {
					highest_held_title_tier = tier_kingdom
					sub_realm_size > 1
					capital_county ?= {
						is_potential_control_county_trigger = yes
					}
				}
				alternative_limit = {
					highest_held_title_tier = tier_duchy
					sub_realm_size > 0
					capital_county ?= {
						is_potential_control_county_trigger = yes
					}
				}			
				alternative_limit = {
					highest_held_title_tier = tier_county
					sub_realm_size > 0
					capital_county ?= {
						is_potential_control_county_trigger = yes
					}
				}	
				alternative_limit = {
					highest_held_title_tier = tier_barony
					capital_county ?= {
						is_potential_control_county_trigger = yes
					}
				}
				scope:councillor = {
					set_council_task = {
						task_type = task_increase_control
						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 = { # Secure sub vassal
				limit = {
					highest_held_title_tier = tier_empire
					sub_realm_size > 1
					capital_county ?= {
						is_potential_control_county_trigger = yes
					}
				}			
				alternative_limit = {
					highest_held_title_tier = tier_kingdom
					sub_realm_size > 1
					capital_county ?= {
						is_potential_control_county_trigger = yes
					}
				}	
				alternative_limit = {
					highest_held_title_tier = tier_duchy
					sub_realm_size > 0
					capital_county ?= {
						is_potential_control_county_trigger = yes
					}
				}			
				alternative_limit = {
					highest_held_title_tier = tier_county
					sub_realm_size > 0
					capital_county ?= {
						is_potential_control_county_trigger = yes
					}
				}	
				alternative_limit = {
					highest_held_title_tier = tier_barony
					capital_county ?= {
						is_potential_control_county_trigger = yes
					}
				}
				scope:councillor = {
					set_council_task = {
						task_type = task_increase_control
						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 = { # Secure other province
				limit = {
					county = {
						is_potential_control_county_trigger = yes
					}
				}
				scope:councillor = {
					set_council_task = {
						task_type = task_increase_control
						target = prev.title_capital_county.title_province
					}
					save_temporary_scope_value_as = {
						name = councillor_on_work
						value = yes
					}
				}
			}
		}
	}
}