﻿##### From CCU submod; used with permission

# What cultural acceptance should two cultures drift down towards if above?
# root = culture 1
# scope:culture = culture 2
# this is calculated late in startup after history setup
culture_acceptance_baseline = {
	value = 0
	if = {
		limit = { # To stop errors in observe mode
			exists = root
			exists = scope:culture

			# Set up some scopes we'll need
			trigger_if = {
				limit = {
					culture_number_of_counties > 0
				}
				calc_culture_dominant_religion = { save_temporary_scope_as = our_religion }
				calc_culture_dominant_faith = { save_temporary_scope_as = our_faith }
			}
			scope:culture = {
				trigger_if = {
					limit = {
						culture_number_of_counties > 0
					}
					calc_culture_dominant_religion = { save_temporary_scope_as = their_religion }
					calc_culture_dominant_faith = { save_temporary_scope_as = their_faith }
				}
			}
		}
		# Increase base acceptance for sharing the same heritage
		if = {
			limit = {
				has_same_culture_heritage = scope:culture
			}
			add = {
				value = same_heritage_cultural_acceptance # please update CULTURE_PILLAR_TOOLTIP_HERITAGE_EFFECT if this number changes
				desc = ACCEPTANCE_BASELINE_HERITAGE
			}
		}
		else_if = {
			limit = { has_same_kulturbund_as_trigger = { TARGET = scope:culture } }
			add = {
				value = same_heritage_kulturbund_cultural_acceptance
				desc = ACCEPTANCE_BASELINE_HERITAGE_KULTURBUND
			}
		}
		else_if = {
			limit = { has_same_heritage_group_as_trigger = { TARGET = scope:culture } }
			add = {
				value = same_heritage_group_cultural_acceptance
				desc = ACCEPTANCE_BASELINE_HERITAGE_GROUP
			}
		}
		else_if = {
			limit = { has_same_heritage_family_as_trigger = { TARGET = scope:culture } }
			add = {
				value = same_heritage_family_cultural_acceptance
				desc = ACCEPTANCE_BASELINE_HERITAGE_FAMILY
			}
		}
		
		# Increase base acceptance for sharing same language
		if = {
			limit = {
				has_same_culture_language = scope:culture
			}
			add = {
				value = same_language_cultural_acceptance # please update CULTURE_PILLAR_TOOLTIP_LANGUAGE_EFFECT if this number changes
				desc = ACCEPTANCE_BASELINE_LANGUAGE
			}
		}
		else_if = {
			limit = { has_same_dialect_continuum_as_trigger = { TARGET = scope:culture } }
			add = {
				value = same_dialect_continuum_cultural_acceptance
				desc = ACCEPTANCE_BASELINE_LANGUAGE_DIALECT_CONTINUUM
			}
		}
		else_if = {
			limit = { has_same_language_group_as_trigger = { TARGET = scope:culture } }
			add = {
				value = same_language_group_cultural_acceptance
				desc = ACCEPTANCE_BASELINE_LANGUAGE_GROUP
			}
		}
		else_if = {
			limit = { has_same_language_branch_as_trigger = { TARGET = scope:culture } }
			add = {
				value = same_language_branch_cultural_acceptance
				desc = ACCEPTANCE_BASELINE_LANGUAGE_BRANCH
			}
		}
		else_if = {
			limit = { has_a_creole_language_trigger = { TARGET = scope:culture } }
			add = {
				value = creole_language_cultural_acceptance
				desc = ACCEPTANCE_BASELINE_LANGUAGE_CREOLE
			}
		}
		else_if = {
			limit = { has_same_language_family_as_trigger = { TARGET = scope:culture } }
			add = {
				value = same_language_family_cultural_acceptance 
				desc = ACCEPTANCE_BASELINE_LANGUAGE_FAMILY
			}
		}
		else_if = {
			limit = { is_in_language_union_with_trigger = { TARGET = scope:culture } }
			add = {
				value = same_language_union_cultural_acceptance 
				desc = ACCEPTANCE_BASELINE_LANGUAGE_UNION
			}
		}
		
		# Decrease base acceptance for differing martial custom
		if = {
			limit = { NOT = { has_same_culture_martial_tradition = scope:culture } }
			add = {
				value = different_martial_tradition_cultural_acceptance
				desc = ACCEPTANCE_BASELINE_MARTIAL_TRADITION
			}
		}
		
		# Increase base acceptance for sharing the same ethos if cultures are present within the same geographical area
		if = {
			limit = {
				has_same_culture_ethos = scope:culture
				OR = {
					cultures_share_relevant_region_trigger = yes
					#In case cultures are bordering each other in two different regions
					any_culture_county = {
						any_neighboring_county = {
							culture = scope:culture
						}
					}
				}
			}
			add = {
				value = 10
				desc = ACCEPTANCE_BASELINE_ETHOS
			}
		}
		# General Faith acceptance modifiers
		if = { # Same Religion
			limit = {
				exists = scope:our_religion
				exists = scope:their_religion
				scope:our_religion = scope:their_religion
				root = {
					any_culture_county = {
						percent >= 0.5
						religion = scope:our_religion
					}
				}
				scope:culture = {
					any_culture_county = {
						percent >= 0.5
						religion = scope:our_religion
					}
				}
			}
			add = {
				value = 5
				desc = ACCEPTANCE_BASELINE_RELIGION
			}
		}
		if = { # Same exact Faith
			limit = {
				exists = scope:our_faith
				exists = scope:their_faith
				scope:our_faith = scope:their_faith
				root = {
					any_culture_county = {
						percent >= 0.5
						faith = scope:our_faith
					}
				}
				scope:culture = {
					any_culture_county = {
						percent >= 0.5
						faith = scope:our_faith
					}
				}
			}
			add = {
				value = 10
				desc = ACCEPTANCE_BASELINE_FAITH
			}
		}
		else_if = {
			limit = { 
				AND = {
					exists = scope:our_faith
					exists = scope:their_faith
					scope:our_faith = { faith_hostility_level = { target = scope:their_faith value = 0 } } 
					scope:their_faith = { faith_hostility_level = { target = scope:our_faith value = 0 } }
				}
			}
			add = {
				value = 5
				desc = ACCEPTANCE_BASELINE_FAITH_RIGHTEOUS
			}
		}
		else_if = {
			limit = { 
				exists = scope:our_faith
				exists = scope:their_faith
				OR = {
					scope:our_faith = { faith_hostility_level = { target = scope:their_faith value = 3 } } 
					scope:their_faith = { faith_hostility_level = { target = scope:our_faith value = 3 } }
				}
			}
			add = {
				value = -20
				desc = ACCEPTANCE_BASELINE_FAITH_EVIL
			}
		}
		else_if = {
			limit = { 
				exists = scope:our_faith
				exists = scope:their_faith
				OR = {
					scope:our_faith = { faith_hostility_level = { target = scope:their_faith value = 2 } } 
					scope:their_faith = { faith_hostility_level = { target = scope:our_faith value = 2 } }
				}
			}
			add = {
				value = -10
				desc = ACCEPTANCE_BASELINE_FAITH_HOSTILE
			}
		}
		
		
		if = { # Eastern faiths
			limit = {
				exists = scope:our_religion
				exists = scope:their_religion
				scope:our_religion = {
					is_in_family = rf_eastern
				}
				scope:their_religion = {
					is_in_family = rf_eastern
				}

				any_culture_county = {
					percent >= 0.5
					title_province = {
						religion = {
							is_in_family = rf_eastern
						}
					}
				}
				scope:culture = {
					any_culture_county = {
						percent >= 0.5
						title_province = {
							religion = {
								is_in_family = rf_eastern
							}
						}
					}
				}
			}
			add = {
				value = 5
				desc = ACCEPTANCE_BASELINE_EASTERN_RELIGION
			}
		}
		if = { # Pluralistic close faiths
			limit = {
				exists = scope:our_faith
				exists = scope:their_faith
				scope:our_faith = {
					has_doctrine = doctrine_pluralism_pluralistic
				}
				scope:their_faith = {
					has_doctrine = doctrine_pluralism_pluralistic
				}
				any_culture_county = {
					percent >= 0.5
					title_province = {
						faith = {
							has_doctrine = doctrine_pluralism_pluralistic
						}
					}
				}
				scope:culture = {
					any_culture_county = {
						percent >= 0.5
						title_province = {
							faith = {
								has_doctrine = doctrine_pluralism_pluralistic
							}
						}
					}
				}
				OR = {
					cultures_share_relevant_region_trigger = yes
					#In case cultures are bordering each other in two different regions
					any_culture_county = {
						any_neighboring_county = {
							culture = scope:culture
						}
					}
				}
			}
			add = {
				value = 10
				desc = ACCEPTANCE_BASELINE_CLOSE_PLURALISTS
			}
		}
	}
}

