@ai_standard_liege_desire = 2
@ai_standard_vassal_desire = 1
# Everything below this line is 'Fine Print'

special_contract = {
	display_mode = radiobutton
	is_shown = {
		scope:vassal.primary_title.tier >= tier_county
	}
	obligation_levels = {
		special_contract_none = {
			position = { 0 1 }
			default = yes
			score = 0

			ai_vassal_desire =  {
				value = 0
				if = {
					limit = {
						scope:vassal = {
							vassal_contract_has_flag = has_scutage_contract
							OR = {
								government_has_flag = government_is_clan
								AND = {
									government_has_flag = government_is_feudal
									vassal_contract_obligation_level:feudal_government_taxes >= feudal_tax_normal_level
								}
							}
						}
					}
					add = @ai_standard_vassal_desire
				}
			}


			ai_liege_desire =  {
				value = 0
				if = {
					limit = {
						scope:vassal = {
							vassal_contract_has_flag = has_scutage_contract
							OR = {
								government_has_flag = government_is_clan
								AND = {
									government_has_flag = government_is_feudal
									vassal_contract_obligation_level:feudal_government_taxes < feudal_tax_normal_level
								}
							}
						}
					}
					add = @ai_standard_liege_desire
				}
				if = {
					limit = {
						scope:vassal = {
							vassal_contract_has_flag = has_march_contract
							OR = {
								government_has_flag = government_is_clan
								AND = {
									government_has_flag = government_is_feudal
									vassal_contract_obligation_level:feudal_government_levies < feudal_levies_normal_level
								}
							}
						}
					}
					add = @ai_standard_liege_desire
				}
				if = {
					limit = {
						scope:vassal = {
							vassal_contract_has_flag = has_palatinate_contract

							OR = {
								government_has_flag = government_is_clan
								AND = {
									government_has_flag = government_is_feudal
									OR = {
										vassal_contract_obligation_level:feudal_government_taxes >= feudal_tax_normal_level
										vassal_contract_obligation_level:feudal_government_levies >= feudal_levies_normal_level
									}
								}
							}
						}
					}
					add = @ai_standard_liege_desire
				}
			}
		}
		special_contract_scutage = {
			is_shown = {
				scope:vassal.primary_title.tier >= tier_duchy
				scope:vassal = { government_has_flag = government_is_feudal }
			}
			is_valid = {
				scope:liege.culture = {
					has_innovation = innovation_scutage
				}
			}
			parent = special_contract_none
			position = { 1 1 }
			score = 0

			tax_factor = scutage_contract_tax
			levies_factor = -0.75

			vassal_modifier = {
				men_at_arms_maintenance = -0.2
			}

			flag = has_scutage_contract
			flag = obligation_high_taxes

			ai_liege_desire =  {
				value = 0
				if = {
					limit = {
						scope:vassal = {
							OR = {
								government_has_flag = government_is_clan
								AND = {
									government_has_flag = government_is_feudal
									vassal_contract_obligation_level:feudal_government_taxes > feudal_tax_normal_level
									vassal_contract_obligation_level:feudal_government_levies < feudal_levies_normal_level
								}
							}
						}
					}
					add = @ai_standard_liege_desire
				}
				if = {
					limit = {
						scope:liege = {
							ai_should_focus_on_building_in_their_capital = yes
						}
					}
					add = 10
				}
			}
		}
		special_contract_march = {
			is_shown = {
				scope:vassal.primary_title.tier >= tier_duchy
			}
			is_valid = {
				scope:liege.culture = {
					has_innovation = innovation_bannus
				}
				custom_tooltip = {
					text = special_contract_march_border_trigger
					scope:vassal = {
						OR = {
							vassal_contract_has_flag = has_march_contract
							primary_title = { has_variable = historical_margrave }
							any_sub_realm_county = {
								any_neighboring_county = {
									NOT = { holder.top_liege = scope:vassal.top_liege }
								}
							}
						}
					}
				}
			}
			parent = special_contract_none
			position = { 1 0 }
			score = 0

			tax_factor = march_contract_taxes

			vassal_modifier = {
				levy_size = 0.2
				army_maintenance_mult = -0.2
				garrison_size = 0.2
				levy_reinforcement_rate = 0.2
				controlled_province_advantage = 5
			}

			flag = has_march_contract

			ai_liege_desire =  {
				value = 0
				if = {
					limit = {
						scope:vassal = {
							OR = {
								government_has_flag = government_is_clan
								AND = {
									government_has_flag = government_is_feudal
									OR = {
										vassal_contract_obligation_level:feudal_government_taxes < feudal_tax_normal_level
										vassal_contract_obligation_level:feudal_government_levies > feudal_levies_normal_level
									}
								}
							}
						}
					}
					add = @ai_standard_liege_desire
				}
			}
		}
		special_contract_castellan = {
			is_shown = {
				scope:vassal.primary_title.tier = tier_county
			}
			is_valid = {
				scope:liege.culture = {
					has_innovation = innovation_bannus
				}
			}
			parent = special_contract_none
			position = { 1 0 }
			score = 0

			tax_factor = march_contract_taxes
			levies_factor = 0.5

			vassal_modifier = {
				levy_size = 0.2
				army_maintenance_mult = -0.2
				garrison_size = 0.2
				levy_reinforcement_rate = 0.2
				controlled_province_advantage = 5
			}

			flag = has_castellan_contract
			flag = obligation_high_levies

			ai_liege_desire =  {
				value = 0
				if = {
					limit = {
						scope:vassal = {
							OR = {
								government_has_flag = government_is_clan
								AND = {
									government_has_flag = government_is_feudal
									OR = {
										vassal_contract_obligation_level:feudal_government_taxes < feudal_tax_normal_level
										vassal_contract_obligation_level:feudal_government_levies > feudal_levies_normal_level
									}
								}
							}
						}
					}
					add = @ai_standard_liege_desire
				}
			}
		}
		special_contract_palatinate = {
			is_shown = { scope:vassal = { government_has_flag = government_is_feudal } }
			is_valid = {
				scope:liege.culture = {
					has_innovation = innovation_divine_right
				}
			}
			parent = special_contract_none
			position = { 1 2 }
			score = 0

			tax_factor = palatinate_contract_taxes
			levies_factor = palatinate_contract_levies

			liege_modifier = {
				monthly_prestige_gain_mult = 0.05
			}

			vassal_modifier = {
				monthly_prestige_gain_mult = 0.2
				fellow_vassal_opinion = 15
				owned_personal_scheme_success_chance_add = 10
				owned_hostile_scheme_success_chance_add = 10
			}

			flag = has_palatinate_contract

			ai_liege_desire =  {
				value = 0
				if = {
					limit = {
						scope:vassal = {
							government_has_flag = government_is_feudal
							vassal_contract_obligation_level:feudal_government_taxes < feudal_tax_low_level
							vassal_contract_obligation_level:feudal_government_levies < feudal_levies_low_level
						}
					}
					add = @ai_standard_liege_desire
				}
			}
		}
	}
}

religious_rights = {
	display_mode = checkbox
	is_shown = {
		NOT = {
			scope:vassal.faith = scope:liege.faith
		}
		OR = {
			NOT = {
				scope:liege.faith = {
					OR = {
						has_doctrine = tenet_tax_nonbelievers
						has_doctrine = special_doctrine_jizya
					}
				}
			}
			AND = {
				scope:liege.faith = {
					OR = {
						has_doctrine = tenet_tax_nonbelievers
						has_doctrine = special_doctrine_jizya
					}
				}
				scope:vassal = {
					NOT = {
						vassal_contract_has_flag = vassal_contract_cannot_revoke_titles
					}
					vassal_contract_has_flag = religiously_protected
				}
			}
		}
	}
	obligation_levels = {
		religious_rights_none = {
			default = yes
			position = { 0 0 }

			ai_liege_desire = @ai_standard_liege_desire
			ai_vassal_desire = 0
		}
		religious_rights_protected = {
			is_valid = {
				NOT = {
					scope:vassal.faith = scope:liege.faith
				}
			}
			parent = religious_rights_none
			position = { 1 0 }

			vassal_opinion = 5

			vassal_modifier = {
				county_opinion_add = 5
			}

			flag = religiously_protected

			ai_liege_desire = 0
			ai_vassal_desire = 10
		}
	}
}

fortification_rights = {
	display_mode = checkbox
	is_shown = {
		scope:liege.culture = {
			has_innovation = innovation_battlements
		}
	}
	obligation_levels = {
		fortification_rights_none = {
			default = yes
			position = { 0 0 }

			ai_liege_desire = @ai_standard_liege_desire
			ai_vassal_desire = 0
		}
		fortification_rights_granted = {
			is_valid = {
				scope:liege.culture = {
					has_innovation = innovation_battlements
				}
			}
			parent = fortification_rights_none
			position = { 1 0 }

			liege_modifier = {
				castle_holding_build_gold_cost = 0.05
			}

			vassal_modifier = {
				castle_holding_build_gold_cost = -0.15
				castle_holding_holding_build_gold_cost = -0.5
				additional_fort_level = 1
			}

			tax_factor = fortification_rights_contract_taxes

			ai_liege_desire = 0
			ai_vassal_desire = @ai_standard_vassal_desire
		}
	}
}

coinage_rights = {
	display_mode = checkbox
	is_shown = {
		scope:liege.culture = {
			has_innovation = innovation_currency_02
		}
	}
	obligation_levels = {
		coinage_rights_none = {
			default = yes
			position = { 0 0 }

			ai_liege_desire = @ai_standard_liege_desire
			ai_vassal_desire = 0
		}
		coinage_rights_granted = {
			is_valid = {
				scope:liege.culture = {
					has_innovation = innovation_currency_02
				}
			}
			parent = coinage_rights_none
			position = { 1 0 }

			liege_modifier = {
				development_growth_factor = -0.02
			}
			vassal_modifier = {
				character_capital_county_monthly_development_growth_add = 0.3
			}

			ai_liege_desire = 0
			ai_vassal_desire = @ai_standard_vassal_desire
		}
	}
}

succession_rights = {
	display_mode = checkbox
	is_shown = {
		scope:vassal = {
			can_have_confederate_partition_succession_law_trigger = yes
		}
	}
	obligation_levels = {
		succession_rights_default = {
			default = yes
			position = { 0 0 }

			ai_liege_desire = 0
			ai_vassal_desire = @ai_standard_vassal_desire
		}
		succession_rights_forced_partition = {
			is_valid = {
				scope:vassal = {
					can_have_confederate_partition_succession_law_trigger = yes
				}
			}
			score = -1
			parent = succession_rights_default
			position = { 1 0 }

			vassal_opinion = -5

			flag = locked_to_partition

			ai_liege_desire = @ai_standard_liege_desire
			ai_vassal_desire = 0
		}
	}
}

war_declaration_rights = {
	display_mode = checkbox
	obligation_levels = {
		war_declaration_rights_default = {
			default = yes
			position = { 0 0 }

			ai_liege_desire = @ai_standard_liege_desire
			ai_vassal_desire = 0
		}
		war_declaration_rights_allowed = {
			parent = war_declaration_rights_default
			position = { 1 0 }

			vassal_opinion = 5

			flag = vassal_contract_war_override

			ai_liege_desire = 0
			ai_vassal_desire = @ai_standard_vassal_desire
		}
	}
}

council_rights = {
	display_mode = checkbox
	obligation_levels = {
		council_rights_none = {
			default = yes
			position = { 0 0 }

			ai_liege_desire = @ai_standard_liege_desire
			ai_vassal_desire = 0
		}
		council_rights_guaranteed = {
			parent = council_rights_none
			position = { 1 0 }

			vassal_opinion = 5

			flag = can_demand_council_seat

			liege_modifier = {
				powerful_vassal_opinion = -2
			}

			ai_liege_desire = 0
			ai_vassal_desire = @ai_standard_vassal_desire
		}
	}
}

title_revocation_rights = {
	display_mode = checkbox
	is_shown = {
		OR = {
			scope:vassal.faith = scope:liege.faith
			NOR = {
				scope:vassal.faith = scope:liege.faith
				scope:liege.faith = {
					has_doctrine_parameter = unlock_jizya_contract
				}
			}
		}
	}
	obligation_levels = {
		title_revocation_rights_default = {
			default = yes
			position = { 0 0 }

			ai_liege_desire = 1
			ai_vassal_desire = 0
		}
		title_revocation_rights_protected = {
			is_valid = {
				OR = {
					scope:vassal.faith = scope:liege.faith
					NOR = {
						scope:vassal.faith = scope:liege.faith
						scope:liege.faith = {
							has_doctrine_parameter = unlock_jizya_contract
						}
					}
				}
			}

			parent = title_revocation_rights_default
			position = { 1 0 }

			vassal_opinion = 5

			flag = vassal_contract_cannot_revoke_titles

			ai_liege_desire = 0
			ai_vassal_desire = @ai_standard_vassal_desire
		}
	}
}

jizya_special_rights = {
	display_mode = checkbox
	is_shown = {
		scope:liege.faith = {
			OR = {
				has_doctrine = tenet_tax_nonbelievers
				has_doctrine = special_doctrine_jizya
			}
		}
		NOT = {	scope:vassal.faith = scope:liege.faith }
		scope:vassal = {
			OR = {
				NOT = {
					vassal_contract_has_flag = religiously_protected
				}
				AND = {
					vassal_contract_has_flag = religiously_protected
					vassal_contract_has_flag = vassal_contract_cannot_revoke_titles
				}
			}
		}
	}

	obligation_levels = {
		jizya_special_rights_default = {
			default = yes
			position = { 0 0 }

			ai_liege_desire = 1
			ai_vassal_desire = 0
		}
		jizya_special_rights_granted = {
			is_valid = {
				scope:liege.faith = {
					OR = {
						has_doctrine = tenet_tax_nonbelievers
						has_doctrine = special_doctrine_jizya
					}
				}
				NOT = {	scope:vassal.faith = scope:liege.faith }
			}
			parent = jizya_special_rights_default
			position = { 1 0 }

			vassal_opinion = 20
			tax_factor = 0.4
			levies_factor = -0.4

			vassal_modifier = {
				monthly_prestige = -0.25
			}

			flag = vassal_contract_cannot_revoke_titles
			flag = religiously_protected
			flag = obligation_high_taxes

			ai_liege_desire = @ai_standard_liege_desire
			ai_vassal_desire = 0
		}
	}
}

iqta_special_rights = {
	display_mode = checkbox

	obligation_levels = {
		iqta_special_rights_default = {
			default = yes
			position = { 0 0 }

			ai_liege_desire = 1
			ai_vassal_desire = 0
		}
		iqta_special_rights_granted = {
			parent = iqta_special_rights_default
			position = { 1 0 }

			vassal_opinion = 5
			tax_factor = -0.5
			levies_factor = -0.5

			liege_modifier = {
				men_at_arms_maintenance = -0.02
				men_at_arms_recruitment_cost = -0.02
			}

			vassal_modifier = {
				men_at_arms_maintenance = -0.1
				men_at_arms_recruitment_cost = -0.1
			}

			ai_liege_desire = 0
			ai_vassal_desire = @ai_standard_vassal_desire
		}
	}
}

ghazi_special_rights = {
	display_mode = checkbox
	is_shown = {
		scope:vassal.faith = scope:liege.faith
	}
	obligation_levels = {
		ghazi_special_rights_default = {
			default = yes
			position = { 0 0 }

			ai_liege_desire = 1
			ai_vassal_desire = 0
		}
		ghazi_special_rights_granted = {
			is_valid = {
				scope:vassal.faith = scope:liege.faith
			}
			parent = ghazi_special_rights_default
			position = { 1 0 }

			vassal_opinion = 10
			levies_factor = -0.25

			liege_modifier = {
				monthly_piety_gain_mult = 0.1
			}

			vassal_modifier = {
				monthly_piety_gain_mult = 0.1

			}

			flag = vassal_contract_cheaper_religious_war
			flag = vassal_contract_increase_prestige_cb_cost

			ai_liege_desire = @ai_standard_liege_desire
			ai_vassal_desire = @ai_standard_vassal_desire
		}
	}
}

marriage_favor_rights = {
	display_mode = checkbox
	obligation_levels = {
		marriage_favor_rights_default = {
			default = yes
			position = { 0 0 }

			ai_liege_desire = 1
			ai_vassal_desire = 0
		}
		marriage_favor_rights_granted = {
			parent = marriage_favor_rights_default
			position = { 1 0 }

			vassal_opinion = 20
			tax_factor = 0.1
			levies_factor = 0.1

			flag = vassal_contract_marriage_favor
			flag = obligation_high_taxes
			flag = obligation_high_levies

			ai_liege_desire = 0
			ai_vassal_desire = @ai_standard_vassal_desire
		}
	}
}
