#############################
# NOMADIC MIGRATION CONTRACTS
#############################
nomadic_migration_contract_1 = { # Disagreeable Herders
	group = nomadic_settling_group
	icon = "gfx/interface/icons/government_types/government_type_herder.dds"
	use_diplomatic_range = no
	travel = no

	valid_to_create = { settlement_issue_valid_to_create_default_trigger = yes }

	valid_to_keep = { settlement_issue_valid_to_keep_default_trigger = yes }

	valid_to_continue = { settlement_issue_valid_to_continue_default_trigger = yes }

	valid_to_accept = { is_available = yes }

	on_create = { settlement_issue_on_create_effect = yes }

	on_accepted = {
		settlement_issue_on_accepted_default_effect = {
			NUMBER = 1
			ARRIVAL_ID = 0005
			RESET_ID = 0003
		}
	}

	on_completed = {
		task_contract_taker = { remove_variable = nomadic_migration_contract_1 }
	}

	on_invalidated = {
		settlement_issue_on_invalidated_default_effect = yes
	}

	task_contract_reward = {
		control = { effect = { settlement_issue_control_reward_effect = yes } }

		herd = { effect = { settlement_issue_herd_reward_effect = yes } }

		fertility = { effect = { settlement_issue_fertility_reward_effect = yes } }
	}
}

nomadic_migration_contract_2 = { # The Wild Herd
	group = nomadic_settling_group
	icon = "gfx/interface/icons/icon_herd.dds"
	use_diplomatic_range = no
	travel = no

	valid_to_create = { settlement_issue_valid_to_create_default_trigger = yes }

	valid_to_keep = { settlement_issue_valid_to_keep_default_trigger = yes }

	valid_to_continue = { settlement_issue_valid_to_continue_default_trigger = yes }

	valid_to_accept = { is_available = yes }

	on_create = { settlement_issue_on_create_effect = yes }

	on_accepted = {
		settlement_issue_on_accepted_default_effect = {
			NUMBER = 2
			ARRIVAL_ID = 0015
			RESET_ID = 0013
		}
	}

	on_completed = {
		task_contract_taker = { remove_variable = nomadic_migration_contract_2 }
	}

	on_invalidated = {
		settlement_issue_on_invalidated_default_effect = yes
	}

	task_contract_reward = {
		control = { effect = { settlement_issue_control_reward_effect = yes } }

		herd = { effect = { settlement_issue_herd_reward_effect = yes } }

		gold = { effect = { settlement_issue_gold_reward_effect = yes } }

		opinion = { effect = { settlement_issue_opinion_reward_effect = { MODIFIER = mpo_si_slaughtered_for_a_feast } } }
	}
}

nomadic_migration_contract_3 = { # Contentious Grazelands
	group = nomadic_settling_group
	icon = "gfx/interface/icons/icon_county_fertility.dds"
	use_diplomatic_range = no
	travel = no

	valid_to_create = { 
		any_knight = {
			count >= 2
			is_landed = no
		}
		any_held_county = {
			county_control < 90
			NOT = { has_county_modifier = ongoing_settlement_contract }
		}
	}

	valid_to_keep = { settlement_issue_valid_to_keep_default_trigger = yes }

	valid_to_continue = { settlement_issue_valid_to_continue_default_trigger = yes }

	valid_to_accept = { is_available = yes }

	on_create = { settlement_issue_on_create_effect = yes }

	on_accepted = {
		settlement_issue_on_accepted_default_effect = {
			NUMBER = 3
			ARRIVAL_ID = 0025
			RESET_ID = 0023
		}
	}

	on_completed = {
		task_contract_taker = { remove_variable = nomadic_migration_contract_3 }
	}

	on_invalidated = {
		settlement_issue_on_invalidated_default_effect = yes
	}

	task_contract_reward = {
		control = { effect = { settlement_issue_control_reward_effect = yes } }

		herd = { effect = { settlement_issue_herd_reward_effect = yes } }

		opinion = { 
			effect = {
				settlement_issue_character_opinion_reward_effect = {
					CHARACTER = root.task_contract_employer
				}
			}
		}
	}
}

nomadic_migration_contract_4 = { # A Lack of Tools
	group = nomadic_settling_group
	icon = "gfx/interface/icons/court_position_types/royal_architect_court_position.dds"
	use_diplomatic_range = no
	travel = no

	valid_to_create = { settlement_issue_valid_to_create_default_trigger = yes }

	valid_to_keep = { settlement_issue_valid_to_keep_default_trigger = yes }

	valid_to_continue = { settlement_issue_valid_to_continue_default_trigger = yes }

	valid_to_accept = { is_available = yes }

	on_create = { settlement_issue_on_create_effect = yes }

	on_accepted = {
		settlement_issue_on_accepted_default_effect = {
			NUMBER = 4
			ARRIVAL_ID = 0035
			RESET_ID = 0033
		}
	}

	on_completed = {
		task_contract_taker = { remove_variable = nomadic_migration_contract_4 }
	}

	on_invalidated = {
		settlement_issue_on_invalidated_default_effect = yes
	}

	task_contract_reward = {
		control = { effect = { settlement_issue_control_reward_effect = yes } }
	}
}

nomadic_migration_contract_5 = { # Fragmentation of the Tribe
	group = nomadic_settling_group
	icon = "gfx/interface/icons/casus_bellis/ducal_conquest_cb.dds"
	use_diplomatic_range = no
	travel = no

	valid_to_create = { settlement_issue_valid_to_create_default_trigger = yes }

	valid_to_keep = { settlement_issue_valid_to_keep_default_trigger = yes }

	valid_to_continue = { settlement_issue_valid_to_continue_default_trigger = yes }

	valid_to_accept = { is_available = yes }

	on_create = { settlement_issue_on_create_effect = yes }

	on_accepted = {
		settlement_issue_on_accepted_default_effect = {
			NUMBER = 5
			ARRIVAL_ID = 0045
			RESET_ID = 0043
		}
	}

	on_completed = {
		task_contract_taker = { remove_variable = nomadic_migration_contract_5 }
	}

	on_invalidated = {
		settlement_issue_on_invalidated_default_effect = yes
	}

	task_contract_reward = {
		control = { effect = { settlement_issue_control_reward_effect = yes } }
	}
}

nomadic_migration_contract_6 = { # Poisonous Lands
	group = nomadic_settling_group
	icon = "gfx/interface/icons/court_position_types/court_physician_court_position.dds"
	use_diplomatic_range = no
	travel = no

	valid_to_create = { settlement_issue_valid_to_create_default_trigger = yes }

	valid_to_keep = { settlement_issue_valid_to_keep_default_trigger = yes }

	valid_to_continue = { settlement_issue_valid_to_continue_default_trigger = yes }

	valid_to_accept = { is_available = yes }

	on_create = { settlement_issue_on_create_effect = yes }

	on_accepted = {
		settlement_issue_on_accepted_default_effect = {
			NUMBER = 6
			ARRIVAL_ID = 0055
			RESET_ID = 0053
		}
	}

	on_completed = {
		task_contract_taker = { remove_variable = nomadic_migration_contract_6 }
	}

	on_invalidated = {
		settlement_issue_on_invalidated_default_effect = yes
	}

	task_contract_reward = {
		control = { effect = { settlement_issue_control_reward_effect = yes } }
	}
}

nomadic_migration_contract_7 = { # Troublesome Neighbors
	group = nomadic_settling_group
	icon = "gfx/interface/icons/casus_bellis/ducal_conquest_cb.dds"
	use_diplomatic_range = no
	travel = no

	valid_to_create = { settlement_issue_valid_to_create_default_trigger = yes }

	valid_to_keep = {
		custom_tooltip = {
			text = migration_contract_county_ownership_text
			OR = {
				task_contract_location.province_owner = task_contract_taker
				task_contract_location.province_owner.liege = task_contract_taker
				task_contract_location.province_owner.top_liege = task_contract_taker
			}
		}
		custom_tooltip = {
			text = migration_contract_county_alt_text
			task_contract_location.county = { 
				county_control < 90 
				any_neighboring_county = {
					NOT = { owner.top_liege ?= root.top_liege }
				}
			}
		}
	}

	valid_to_continue = { settlement_issue_valid_to_continue_default_trigger = yes }

	valid_to_accept = { is_available = yes }

	on_create = { settlement_issue_on_create_effect = yes }

	on_accepted = {
		settlement_issue_on_accepted_default_effect = {
			NUMBER = 7
			ARRIVAL_ID = 0065
			RESET_ID = 0063
		}
	}

	on_completed = {
		task_contract_taker = { remove_variable = nomadic_migration_contract_7 }
	}

	on_invalidated = {
		settlement_issue_on_invalidated_default_effect = yes
	}

	task_contract_reward = {
		control = { effect = { settlement_issue_control_reward_effect = yes } }

		herd = { effect = { settlement_issue_herd_reward_effect = yes } }
	}
}

nomadic_migration_contract_8 = { # The Leftovers
	group = nomadic_settling_group
	icon = "gfx/interface/icons/icon_herd.dds"
	use_diplomatic_range = no
	travel = no

	valid_to_create = { settlement_issue_valid_to_create_default_trigger = yes }

	valid_to_keep = { settlement_issue_valid_to_keep_default_trigger = yes }

	valid_to_continue = { settlement_issue_valid_to_continue_default_trigger = yes }

	valid_to_accept = { is_available = yes }

	on_create = { settlement_issue_on_create_effect = yes }

	on_accepted = {
		settlement_issue_on_accepted_default_effect = {
			NUMBER = 8
			ARRIVAL_ID = 0075
			RESET_ID = 0073
		}
	}

	on_completed = {
		task_contract_taker = { remove_variable = nomadic_migration_contract_8 }
	}

	on_invalidated = {
		settlement_issue_on_invalidated_default_effect = yes
	}

	task_contract_reward = {
		control = { effect = { settlement_issue_control_reward_effect = yes } }

		herd = { effect = { settlement_issue_herd_reward_effect = yes } }

		gold = { effect = { settlement_issue_gold_reward_effect = yes } }

		fertility = { effect = { settlement_issue_fertility_reward_effect = yes } }
	}
}

nomadic_migration_contract_9 = { # Drawing Lines
	group = nomadic_settling_group
	icon = "gfx/interface/icons/icon_county_fertility.dds"
	use_diplomatic_range = no
	travel = no

	valid_to_create = { settlement_issue_valid_to_create_default_trigger = yes }

	valid_to_keep = {
		custom_tooltip = {
			text = migration_contract_county_ownership_text
			OR = {
				task_contract_location.province_owner = task_contract_taker
				task_contract_location.province_owner.liege = task_contract_taker
				task_contract_location.province_owner.top_liege = task_contract_taker
			}
		}
		custom_tooltip = {
			text = migration_contract_county_alt_text
			task_contract_location.county = { 
				county_control < 90 
				any_neighboring_county = {
					holder = root.task_contract_taker
				}
			}
		}
	}

	valid_to_continue = { settlement_issue_valid_to_continue_default_trigger = yes }

	valid_to_accept = { is_available = yes }

	on_create = { settlement_issue_on_create_effect = yes }

	on_accepted = {
		settlement_issue_on_accepted_default_effect = {
			NUMBER = 9
			ARRIVAL_ID = 0085
			RESET_ID = 0083
		}
	}

	on_completed = {
		task_contract_taker = { remove_variable = nomadic_migration_contract_9 }
	}

	on_invalidated = {
		settlement_issue_on_invalidated_default_effect = yes
	}

	task_contract_reward = {
		control = { effect = { settlement_issue_control_reward_effect = yes } }

		fertility = { effect = { settlement_issue_fertility_reward_effect = yes } }
	}
}

nomadic_migration_contract_10 = { # The Old Tribe
	group = nomadic_settling_group
	icon = "gfx/interface/icons/icon_culture.dds"
	use_diplomatic_range = no
	travel = no

	valid_to_create = { settlement_issue_valid_to_create_default_trigger = yes }

	valid_to_keep = {
		custom_tooltip = {
			text = migration_contract_county_ownership_text
			OR = {
				task_contract_location.province_owner = task_contract_taker
				task_contract_location.province_owner.liege = task_contract_taker
				task_contract_location.province_owner.top_liege = task_contract_taker
			}
		}
		custom_tooltip = {
			text = migration_contract_county_alt_text
			task_contract_location.county = { 
				county_control < 90 
				has_variable = migration_previous_culture
				NOT = { var:migration_previous_culture = root.task_contract_taker.culture }
			}
		}
	}

	valid_to_continue = { settlement_issue_valid_to_continue_default_trigger = yes }

	valid_to_accept = { is_available = yes }

	on_create = { settlement_issue_on_create_effect = yes }

	on_accepted = {
		settlement_issue_on_accepted_default_effect = {
			NUMBER = 10
			ARRIVAL_ID = 0095
			RESET_ID = 0093
		}
	}

	on_completed = {
		task_contract_taker = { remove_variable = nomadic_migration_contract_10 }
	}

	on_invalidated = {
		settlement_issue_on_invalidated_default_effect = yes
	}

	task_contract_reward = {
		control = { effect = { settlement_issue_control_reward_effect = yes } }

		herd = { effect = { settlement_issue_herd_reward_effect = yes } }
		
		success = { effect = { settlement_issue_culture_reward_effect = yes } }
	}
}
