﻿court_language_ai_score = {
	add = scope:their_language_counties

	# Bit of relative score for percentage too
	add = {
		value = scope:their_language_counties
		multiply = 10
		divide = scope:total_counties
	}
	if = {
		limit = { scope:checking_native_language = no }
		subtract = scope:my_language_counties
	}

	#Adjust for Court Grandeur.
	#World religions primarily cares about other courts that share their faith.
	add = {
		value = 0
		#AGOT Disabled
		# if = {	#Islamic rulers cares about islamic courts
		# 	limit = {
		# 		faith.religion = religion:islam_religion
		# 		scope:target.faith.religion = religion:islam_religion
		# 	}
		# 	add = {
		# 		value = scope:target.court_grandeur_current
		# 		if = { #Reduce further if not same faith
		# 			limit = {
		# 				NOT = { faith = scope:target.faith }
		# 			}
		# 			divide = 2
		# 		}
		# 	}
		# }
		#AGOT Disabled
		# else_if = {	#Christian cares about other Christians - especially of the same faith
		# 	limit = {
		# 		faith.religion = religion:christianity_religion
		# 		scope:target.faith.religion = religion:christianity_religion
		# 	}
		# 	add = {
		# 		value = scope:target.court_grandeur_current
		# 		if = { #Reduce further if not same faith
		# 			limit = {
		# 				NOT = { faith = scope:target.faith }
		# 			}
		# 			divide = 3
		# 		}
		# 	}
		# }
		#AGOT Disabled
		# else_if = {	#Eastern Faiths
		# 	limit = {
		# 		OR = {
		# 			faith.religion = religion:hinduism_religion
		# 			faith.religion = religion:buddhism_religion
		# 			faith.religion = religion:jainism_religion
		# 		}
		# 		OR = {
		# 			scope:target.faith.religion = religion:hinduism_religion
		# 			scope:target.faith.religion = religion:buddhism_religion
		# 			scope:target.faith.religion = religion:jainism_religion
		# 		}
		# 	}
		# 	add = {
		# 		value = scope:target.court_grandeur_current
		# 		if = { #Reduce further if not same Religion
		# 			limit = {
		# 				NOT = { faith.religion = scope:target.faith.religion }
		# 			}
		# 			divide = 2
		# 		}
		# 	}
		# }
		#AGOT Disabled
		# else_if = { #Abrahamic religion matching vs non co-religionist - CGV Ignored
		# 	limit = {
		# 		OR = {
		# 			faith.religion = religion:islam_religion
		# 			faith.religion = religion:christianity_religion
		# 		}
		# 		NOT = { faith.religion = scope:target.faith.religion }
		# 	}
		# 	#Add nothing
		# }
		#AGOT Disabled
		# else_if = { #Eastern religion matching vs non Eastern religion - CGV Ignored
		# 	limit = {
		# 		OR = {
		# 			faith.religion = religion:hinduism_religion
		# 			faith.religion = religion:buddhism_religion
		# 			faith.religion = religion:jainism_religion
		# 		}
		# 		NOR = {
		# 			scope:target.faith.religion = religion:hinduism_religion
		# 			scope:target.faith.religion = religion:buddhism_religion
		# 			scope:target.faith.religion = religion:jainism_religion
		# 		}
		# 	}
		# 	#Add nothing
		# }
		#AGOT Addded, fots cares about other fots - especially of the same faith
		if = {
			limit = {
				faith.religion = religion:faith_of_the_seven_religion
				scope:target.faith.religion = religion:faith_of_the_seven_religion
			}
			add = {
				value = scope:target.court_grandeur_current
				if = { #Reduce further if not same faith
					limit = {
						NOT = { faith = scope:target.faith }
					}
					divide = 2
				}
			}
		}
		else = { #Everyone else just cares about the Grandeur directly
			add = scope:target.court_grandeur_current
		}
	}


	#Increase from number of other courts using the Language (1.5 per court).
	add = {
		value = scope:courts_with_language
		multiply = 1.5
	}

	#Arbitrary Geographical Bias - if our courts are not in the same region the score is divided by 2.
	divide = {
		value = 1
		if = {
			limit = {
				OR = {
					#AGOT Disabled
					#Europe:
					# AND = {
					# 	capital_province = { geographical_region = world_europe_west_britannia }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_europe_west_britannia } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_europe_west_germania }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_europe_west_germania } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_europe_west_francia }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_europe_west_francia } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_europe_west_iberia }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_europe_west_iberia } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_europe_north }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_europe_north } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_europe_south_east }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_europe_south_east } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_europe_south_italy }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_europe_south_italy } }
					# }
					#AGOT Disabled
					#South Asia:
					# AND = {
					# 	capital_province = { geographical_region = world_india_rajastan }
					# 	scope:target.capital_province = { geographical_region = world_india_rajastan }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_india_bengal }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_india_bengal } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_india_deccan }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_india_deccan } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_burma }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_burma } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_himalaya }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_himalaya } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_middle_east }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_middle_east } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_middle_east_persia }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_middle_east_persia } }
					# }
					#AGOT Disabled
					#Africa
					# AND = {
					# 	capital_province = { geographical_region = world_africa_north }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_africa_north } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_africa_west }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_africa_west } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_africa_east }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_africa_east } }
					# }
					#AGOT Disabled
					#Central Asia
					# AND = {
					# 	capital_province = { geographical_region = world_steppe_west }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_steppe_west } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_steppe_east }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_steppe_east } }
					# }
					# AND = {
					# 	capital_province = { geographical_region = world_tibet }
					# 	NOT = { scope:target.capital_province = { geographical_region = world_tibet } }
					# }
					#AGOT Added, Beyond the Wall
					AND = {
						capital_province = { geographical_region = world_westeros_beyond_the_wall }
						NOT = { scope:target.capital_province = { geographical_region = world_westeros_beyond_the_wall } }
					}
					#AGOT Added, Westeros
					AND = {
						capital_province = { geographical_region = world_westeros_seven_kingdoms }
						NOT = { scope:target.capital_province = { geographical_region = world_westeros_seven_kingdoms } }
					}
				}
			}
			add = 1
		}
	}

	# Prefer the status quo slightly. Needs to be last
	if = {
		limit = {
			scope:checking_native_language = yes
			has_court_language_of_culture = culture
		}
		multiply = 1.5
		add = 1000 # Add a large constant to the score of the current court language
	}
	else_if = {
		limit = {
			scope:checking_native_language = no
			scope:target = { has_royal_court = yes }
			has_same_court_language = scope:target
		}
		multiply = 1.5
		add = 1000 # Add a large constant to the score of the current court language
	}
}