﻿### EK EDIT: Removed references to vanilla religions cultures and characters, and disabled the achievements tracking

# Called from code after history generation
# Empty scope
on_game_start = {
	###EK ADDITION: Plugged our own on_actions
	on_actions = {
		ek_on_game_start_culture
		ek_on_game_start_religion
		#ek_on_game_start_laws #EK NOTE: this is commented out for unknown reason
		ek_on_game_start_bookmark
		ek_on_game_start_events
		ek_on_game_start_effects
		ek_on_game_start_house_feuds
		ek_on_game_start_dynamic_coa
		ek_on_game_start_legitimacy
		ek_on_game_start_praxis
		ek_on_game_start_flavourise
		ek_narrative_events_start
		on_game_start_lunar_cycle
		on_game_start_initialize_patron_status
		ek_on_game_start_fix_history_parents
	}
	#EK ADDITION END
	
	events = {
		fp1_scandinavian_adventurers.0004	# FP1 - Organise Norse adventurers.
		fp1_scandinavian_adventurers.0011	# FP1 - Corral famous Norse adventurers that haven't done much yet.
		fp1_scandinavian_adventurers.0021	# FP1 - Mark game-start prioritised adventurers.
		#Guaranteed historical artifacts fixed spawning
		#EK DISABLED
		#debug_portraits.1 					# Debug portraits for animation testing
		#easteregg_event.0001				# Charna and Jakub duel.
	}

	effect = {
		#Epidemics 3 months grace
		set_global_variable = {
			name = start_epidemic_grace
			value = yes
			months = 3
		}
		#EK DISABLED: vanilla specific setup
		### GAME RULE: EXTRA ADMINS
		apply_historic_administrative_game_rule_effect = yes
		#EK DISABLED: vanilla stuff
		### 1178 CRUSADE SETUP ###
		#if = {
		#	limit = {
		#		game_start_date >= 1178.10.1
		#	}
		#	religion:islam_religion = {
		#		set_variable = { 
		#			name = variable_ghw_unlocked 
		#			value = yes 
		#		}
		#	}
		#	religion:christianity_religion = {
		#		set_variable = { 
		#			name = variable_ghw_unlocked 
		#			value = yes 
		#		}
		#	}
		#	set_global_variable = {
		#		name = had_first_catholic_crusade
		#		value = yes
		#	}
		#}
		#EK TODO COMP 1-13: adapt our holy order event creations to vanilla system
		#if = {
		#	limit = {
		#		game_start_date >= 1178.10.1
		#	}
		#	character:st_amand_1 = {
		#		save_scope_as = leader
		#	}
		#	character:223523 = {
		#		save_scope_as = founder
		#	}
		#	title:b_saida = {
		#		save_scope_as = barony
		#	}
		#	create_holy_order_neutral_effect = {
		#		LEADER = scope:leader
		#		CAPITAL = scope:barony
		#		NEW_HO_SCOPE = new_holy_order
		#		FOUNDER = scope:founder
		#	}
		#}
		#EK DISABLED: removed vanilla universities and coas
		### GRANDEUR ###
		#Royal Court: Set starting Grandeur to be the same as Expected
		if = {
			limit = {
				has_dlc_feature = royal_court
			}
			every_character_with_royal_court = {
				set_current_court_grandeur = court_grandeur_minimum_expected
				apply_hold_court_grace_effect = yes
				# Stops Hold Court reminders at game start
				set_variable = {
					name = last_hold_court_date
					value = current_year
				}
			}
		}

		#### STRUGGLES ###
		#if = {
		#	limit = { current_date = 867.1.1 }
		#
		#	# Iberian Struggle
		#	if = { # If we're in 867, Aragonese should be removed from the Struggle, since they don't quite exist yet.
		#		limit = { exists = struggle:iberian_struggle }
		#		struggle:iberian_struggle = { set_culture_as_uninvolved = culture:aragonese }
		#	}
		#
		#	# Persian Struggle
		#	if = { # If the load order ever changes this struggle is going to break. This must always be read before the struggle.
		#		limit = { exists = struggle:persian_struggle }
		#		debug_log = "Samarra Struggle: Gamne start data has been set"
		#		struggle:persian_struggle = { # Use the object explorer to debug this data (yes, the time has come to learn how to use it)
		#
		#			# Struggle on_start
		#			fp3_remove_vassal_contract_cooldown_for_tension_effect = yes
		#
		#			# Flag some titles as un-dissolutionable within the struggle.
		#			title:e_arabia = { set_variable = struggle_block_dissolution_faction }
		#			title:d_sunni = { set_variable = struggle_block_dissolution_faction }
		#		}
		#	}
		#}

		### REGENCIES ###
		# Pre-defined historic regencies setup.
		## NOTE: we do these first to avoid feed messages getting weird due to regents being replaced immediately after getting their position.
		## 867.
		### None. Yet.
		## 1066.
			#if = {
			#			limit = { game_start_date = 1066.9.15 }
			#			# Designate some regents.
			#			## King Philippe of France & Duke Boudewijn of Flanders (friend of his dad's)
			#			character:214 = {
			#				designate_diarch = character:364
			#				# Baldwin of Flanders also promised the prior king he'd take care of Philippe, so we add that starting loyalty hook.
			#				add_hook = {
			#					type = predecessor_loyalty_hook
			#					target = character:364
			#					years = historic_regent_loyal_after_death_hook_duration_years_char_214_value
			#				}
			#			}
			#			### Plus remember who the promise was made to.
			#			character:364 = {
			#				add_opinion = {
			#					target = character:214
			#					modifier = promise_to_predecessor
			#					opinion = 50
			#				}
			#				set_variable = {
			#					name = promise_to_predecessor
			#					value = character:208
			#					years = historic_regent_loyal_after_death_hook_duration_years_char_214_value
			#				}
			#			}
			#			## Count Bouchard of Vendome & Guy de Bachaumont (his uncle)
			#			character:40905 = { designate_diarch = character:40376 }
			#			## Caliph al-Mustansir & Rasad (his mother)
			#			character:3096 = { designate_diarch = character:additional_fatimids_1 }
			#			## Count Ermengol of Urgell & Infanta Sancha of Aragon (his stepmother)
			#			character:110550 = { designate_diarch = character:110514 }
			#			## Duke Dirk of Holland & Count Robrecht of Zeeland (his stepfather)
			#			character:106520 = { designate_diarch = character:368 }
			#			## Duke Sven of Ostergotland & Kol Sverker (his father)
			#			character:100530 = { designate_diarch = character:100529 }
			#			## King Salamon of Hungary & Queen Mother Anastasia (his mother, in the absence of any better recorded options, and to keep other hostile relatives out of the job)
			#			character:476 = { designate_diarch = character:637 }
			#			## Prince Demetre of Georgia & Alda Oseti (his mother)
			#			character:9957 = { designate_diarch = character:9956 }
			#			## Sultan al-Muazzam Alp Arslan and Hassan "the Order of the Realm".
			#			character:3040 = {
			#				designate_diarch = character:3050
			#				# This is a vizierate as well, so start the diarchy manually.
			#				start_diarchy = vizierate
			#				# Tell Alp that he appointed Hassan so he remembers not to dismiss him.
			#				set_variable = {
			#					name = my_vizier
			#					value = character:3050
			#				}
			#			}
			#			## Constantine X & Michael Doukas.
			#			character:1732 = {
			#				if = {
			#					limit = { has_ep3_dlc_trigger = yes }
			#					start_diarchy = co_emperorship
			#					set_diarch = character:1736
			#					set_designated_heir = character:1736
			#				}
			#			}
			#			# Plus remove all the generated opinions.
			#			## King Philippe of France & Duke Boudewijn of Flanders
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:364
			#				LIEGE = character:214
			#			}
			#			## Count Bouchard of Vendome & Guy de Bachaumont
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:40376
			#				LIEGE = character:40905
			#			}
			#			## Caliph al-Mustansir & Rasad
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:additional_fatimids_1
			#				LIEGE = character:3096
			#			}
			#			## Count Ermengol of Urgell & Infanta Sancha of Aragon
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:110514
			#				LIEGE = character:110550
			#			}
			#			## Duke Dirk of Holland & Count Robrecht of Zeeland
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:368
			#				LIEGE = character:106520
			#			}
			#			## Duke Sven of Ostergotland & Kol Sverker
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:100529
			#				LIEGE = character:100530
			#			}
			#			## King Salamon of Hungary & Queen Mother Anastasia
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:637
			#				LIEGE = character:476
			#			}
			#			## Prince Demetre of Georgia & Alda Oseti
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:9956
			#				LIEGE = character:9957
			#			}
			#			## Sultan al-Muazzam Alp Arslan and Hassan "the Order of the Realm".
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:3050
			#				LIEGE = character:3040
			#			}
			#		}
			#		if = {
			#			limit = { game_start_date = 1178.10.1 }
			#			# Set up some diarchs.
			#			## The future Richard I of England managing Aquitaine in place of his mother (who is under house arrest)
			#			character:205730 = { designate_diarch = character:204510 }
			#			## Jahan Pahlavan Muhammad as regent for Togrul
			#			character:144056 = { designate_diarch = character:144052 }
			#			## Manuel Komnenos and Alexios Komnenos
			#			character:215530 = {
			#				if = {
			#					limit = { has_ep3_dlc_trigger = yes }
			#					start_diarchy = junior_emperorship
			#					set_diarch = character:215531
			#					set_designated_heir = character:215531
			#				}
			#			}
			#			## Henry II of England and the Young King
			#			character:204500 = {
			#				designate_diarch = character:204508
			#				start_diarchy = co_monarchy
			#				set_designated_heir = character:204508
			#			}
			#			## Teresa of Portugal for Afonso the Conqueror
			#			character:209503 = { 
			#				start_diarchy = regency
			#				set_diarch = character:209510 
			#			}
			#			# Plus remove all the generated opinions.
			#			## Richard I and Eleanor of Aquitaine
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:204510
			#				LIEGE = character:205730
			#			}
			#			## Muhammad Jahan Pahlavan and Togrul
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:144052
			#				LIEGE = character:144056
			#			}
			#			## Manuel Komnenos and Alexios
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:215531
			#				LIEGE = character:215530
			#			}
			#			## Henry II and Young Henry
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:204508
			#				LIEGE = character:204500
			#			}
			#			## Teresa and Afonso
			#			remove_generated_diarch_consequences_effect = {
			#				NEW_DIARCH = character:209510
			#				LIEGE = character:209503
			#			}
			#		}
		# Set up anyone who should be in a regency at start whether we have sources or not.
		## If you start as a child, incapable, or imprisoned, you get a regency.
		every_ruler = {
			limit = {
				OR = {
					is_adult = no
					is_incapable = yes
					is_imprisoned = yes
				}
			}
			# We don't want to check over so many characters *twice*, so we check again inside the block to determine what type of regency to put 'em in.
			## Temporary Regencies.
			if = {
				limit = { is_imprisoned = yes }
				trigger_event = {
					id = diarchy.0001
					delayed = yes
				}
			}
			## Entrenched Regencies.
			else = {
				trigger_event = {
					id = diarchy.0011
					delayed = yes
				}
			}
		}
	}
}

# Like on_game_start, except it is called once the host (or player, in single player) exits the lobby. Good for anything where you need to know who the players are, or what the game rules are
on_game_start_after_lobby = {
	#EK ADDITION
	on_actions = {
		on_game_start_players_initialize_patrons
		ek_on_game_start_to_elc
		#on_start_birthsign
		ek_on_game_start_after_lobby
	}
	#EK ADDITION END

	effect = {
		# Make sure that Realm Priests are landed theocrats where it makes sense
		every_ruler = {
			limit = {
				highest_held_title_tier >= tier_duchy
			}
			if = {
				limit = {
					exists = cp:councillor_court_chaplain
					cp:councillor_court_chaplain = {
						is_ruler = no
					}
					faith = { has_doctrine = doctrine_clerical_succession_spiritual_fixed_appointment }
					any_vassal = {
						is_physically_able_adult = yes
						is_councillor = no
						government_has_flag = government_is_theocracy
						can_be_court_chaplain_trigger = { COURT_OWNER = liege }
						faith = liege.faith
					}
				}
				random_vassal = {
					limit = {
						is_physically_able_adult = yes
						is_councillor = no
						government_has_flag = government_is_theocracy
						can_be_court_chaplain_trigger = { COURT_OWNER = liege }
						faith = liege.faith
					}
					weight = {
						base = 1
						modifier = {
							add = 1000
							faith.religious_head ?= this
						}
						modifier = {
							add = learning
						}
						modifier = {
							add = primary_title.tier
						}
					}
					liege = {
						assign_councillor_type = {
							type = councillor_court_chaplain
							remove_existing_councillor = yes
							target = prev
						}
					}
				}
			}
			if = {
				limit = {
					is_landless_adventurer = yes
				}
				if = { limit = { has_realm_law = crown_authority_0 } remove_realm_law = crown_authority_0 }
			}
		}

		### GAME RULE: VIEW ON SAME-SEX RELATIONS
		if = {
			limit = { has_game_rule = accepted_same_sex_relations }
			game_rule_accepted_same_sex_relations_effect = yes
		}

		### GAME RULE: RANDOM RULER PLACEMENT
		if = {
			limit = { NOT = { has_game_rule = random_ruler_placement_off } }
			game_rule_random_ruler_placement_effect = yes
		}

		### GAME RULE: RANDOMIZE FAITH
		if = {
			limit = { has_game_rule = randomized_faiths_on }
			game_rule_randomize_faith_effect = yes
		}

		### GAME RULE: FAITH ACCEPTANCE
		if = {
			limit = { has_game_rule = full_faith_acceptance }
			game_rule_faith_acceptance_effect = yes
		}

		### GAME RULE: GENDER EQUALITY ###
		if = {
			limit = { has_game_rule = full_gender_equality }
			game_rule_full_gender_equality_effect = yes
		}
		else_if = {
			limit = { has_game_rule = inversed_gender_equality }
			game_rule_inversed_gender_equality_effect = yes
		}

		### GAME RULE: SEXUALITY DISTRIBUTION ###
		if = {
			limit = { NOT = { has_game_rule = sexuality_distribution_default } }
			game_rule_sexuality_distribution_effect = yes
		}
		else = { # So that children 10+ starts with a sexuality
			child_sexuality_distribution_effect = yes
		}
		
		### GAME RULE: EXTRA ADMINS
		## We'll be doing some excessive triggers below in a bid to lightly future-proof + error-spam mods less, don't worry about it.
		### We handle players after the lobby.
		# Historic chars.
		apply_historic_administrative_game_rule_effect = yes
		# Players.
		if = {
			limit = { has_dlc_feature = roads_to_power }
			if = {
				limit = {
					NOT = { has_game_rule = historicity_extra_admin_player_wherever_gameplay_not_administrative }
				}
				if = {
					limit = { has_game_rule = historicity_extra_admin_player_wherever_alt_historic_always }
					every_player = {
						limit = {
							highest_held_title_tier >= tier_kingdom
							NOR = {
								government_has_flag = government_is_administrative
								government_has_flag = government_is_landless_adventurer
							}
						}
						convert_to_administrative_from_feudalism_game_start_effect = yes
					}
				}
				else_if = {
					limit = { has_game_rule = historicity_extra_admin_player_wherever_alt_historic_with_august_trait }
					every_player = {
						limit = {
							highest_held_title_tier >= tier_kingdom
							NOR = {
								government_has_flag = government_is_administrative
								government_has_flag = government_is_landless_adventurer
							}
							has_trait = august
						}
						convert_to_administrative_from_feudalism_game_start_effect = yes
					}
				}
			}
		}
		# Give Ruler Designer characters regencies.
		every_in_global_list = {
			variable = rd_chars_needing_regencies
			trigger_event = diarchy.0011
			# Aaaand clean the list.
			save_temporary_scope_as = char_temp
			remove_list_global_variable = {
				name = rd_chars_needing_regencies
				target = scope:char_temp
			}
		}

		### ACHIEVEMENT (FP3): The Ummayad Strikes Back # EK EDIT - no ummayads in this mod
		#every_player = {
		#	if = {
		#		limit = {
		#			dynasty = character:73683.dynasty
		#			location = { geographical_region = world_europe_west_iberia }
		#		}
		#		set_global_variable = fp3_the_umma_strikes_back_achievement_tracker # Is not removed (sad!)
		#	}
		#}
		### ACHIEVEMENT: FROM RAGS TO RICHES
		every_player = {
			limit = { highest_held_title_tier = tier_county }
			add_achievement_global_variable_effect = {
				VARIABLE = achievement_rags_to_riches_valid
				VALUE = yes
			}
		}

		### ACHIEVEMENT (FP2): Holidaying in Iberia
		every_player = {
			limit = { fp2_character_involved_in_struggle_trigger = no }
			add_achievement_global_variable_effect = {
				VARIABLE = fp2_holiday_in_iberia_achievement_unlocked
				VALUE = no # Boolean in actual usage
			}
		}
		# EK EDIT: commented out history-related achievement tracking. kept generic achievements
		### ACHIEVEMENT TRACKING FOR STARTING CHARACTERS
		if = {
			limit = { has_multiple_players = no }
			every_player = {
				# Base Title
				#if = {
				#	limit = { 
				#		exists = character:7757
				#		this = character:7757
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_give_a_dog_a_bone_achievement
				#		VALUE = yes
				#	}
				#}	
				#if = {
				#	limit = { 
				#		exists = character:1128
				#		this = character:1128
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_wily_as_the_fox_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = {
				#		OR = {
				#			AND = {
				#				exists = character:108501
				#				this = character:108501
				#			}
				#			AND = {
				#				exists = character:107500
				#				this = character:107500
				#			}
				#			AND = {
				#				exists = character:107501
				#				this = character:107501
				#			}
				#			AND = {
				#				exists = character:108500
				#				this = character:108500
				#			}
				#			AND = {
				#				exists = character:109500
				#				this = character:109500
				#			}
				#		}
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_sibling_rivalry_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = {
				#		OR = {
				#			AND = {
				#				exists = character:163108
				#				this = character:163108
				#			}
				#			AND = {
				#				exists = character:163110
				#				this = character:163110
				#			}
				#			AND = {
				#				exists = character:163111
				#				this = character:163111
				#			}
				#			AND = {
				#				exists = character:163112
				#				this = character:163112
				#			}
				#			AND = {
				#				exists = character:163119
				#				this = character:163119
				#			}
				#		}
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_blood_eagle_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = {
				#		exists = character:6448
				#		this = character:6448
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_kings_to_the_seventh_generation_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = {
				#		exists = character:140
				#		this = character:140
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_norman_yoke_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = {
				#		exists = character:522
				#		this = character:522
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_royal_dignity_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = {
				#		exists = character:40605
				#		this = character:40605
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_land_of_the_rus_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = {
				#		exists = character:251187
				#		this = character:251187
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_mother_of_us_all_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = {
				#		OR = {
				#			culture = { has_cultural_pillar = heritage_iberian }
				#			culture = culture:andalusian
				#		}
				#		has_religion = religion:christianity_religion
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_reconquista_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = {
				#		culture = culture:irish
				#		capital_province = { geographical_region = custom_ireland }
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_the_emerald_isle_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = {
				#		OR = {
				#			culture = culture:castilian
				#			culture = culture:basque
				#			culture = culture:portuguese
				#			culture = culture:catalan
				#			culture = culture:andalusian
				#			culture = culture:visigothic
				#			culture = culture:suebi
				#		}
				#		has_religion = religion:islam_religion
				#		capital_province = { geographical_region = world_europe_west_iberia }
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_al_andalus_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = { 
				#		exists = character:159137
				#		this = character:159137
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_almost_there_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = { 
				#		exists = character:109607
				#		this = character:109607
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_last_count_first_king_achievement
				#		VALUE = yes
				#	}
				#}
				#if = {
				#	limit = { 
				#		exists = character:6878
				#		this = character:6878
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_going_places_achievement
				#		VALUE = yes
				#	}
				#}
				## FP1
				### far_from_home_achievement
				#if = {
				#	limit = {
				#		# Starting as a Norse pagan Norse-cultured character.
				#		fp1_achievement_culture_plus_religion_norse_trigger = yes
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_far_from_home_achievement
				#		VALUE = yes
				#	}
				#}
				### miklagardariki_achievement
				#if = {
				#	limit = {
				#		# Starting as a Norse pagan Norse-cultured character.
				#		fp1_achievement_culture_plus_religion_norse_trigger = yes
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_miklagardariki_achievement
				#		VALUE = yes
				#	}
				#}
				### canute_the_greater_achievement
				#add_achievement_global_variable_effect = {
				#	VARIABLE = started_canute_the_greater_achievement
				#	VALUE = yes
				#}
				### king_of_all_the_isles_achievement
				#if = {
				#	limit = {
				#		# Starting as a Norse pagan Norse-cultured character.
				#		fp1_achievement_culture_plus_religion_norse_trigger = yes
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_king_of_all_the_isles_achievement
				#		VALUE = yes
				#	}
				#}
				### faster_than_the_fox_achievement
				#if = {
				#	limit = {
				#		# Starting as a Norse pagan Norse-cultured character.
				#		fp1_achievement_culture_plus_religion_norse_trigger = yes
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_faster_than_the_fox_achievement
				#		VALUE = yes
				#	}
				#}
				### volva_achievement
				#if = {
				#	limit = {
				#		# Starting as a Norse pagan Norse-cultured character.
				#		fp1_achievement_culture_plus_religion_norse_trigger = yes
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_volva_achievement
				#		VALUE = yes
				#	}
				#}
				### saga_in_stone_achievement
				add_achievement_global_variable_effect = {
					VARIABLE = started_saga_in_stone_achievement
					VALUE = yes
				}
				### first_of_the_crusader_kings_achievement
				#if = {
				#	limit = {
				#		# Starting as a Norse-cultured character.
				#		fp1_achievement_culture_norse_trigger = yes
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_first_of_the_crusader_kings_achievement
				#		VALUE = yes
				#	}
				#}
				### vladimirs_second_choice_achievement
				#if = {
				#	limit = {
				#		# Starting as a Norse pagan Norse or Rus-cultured character.
				#		fp1_achievement_culture_norse_or_rus_trigger = yes
				#		fp1_achievement_religious_norse_trigger = yes
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_vladimirs_second_choice_achievement
				#		VALUE = yes
				#	}
				#}
				## a_dangerous_business_achievement
				#add_achievement_global_variable_effect = {
				#	VARIABLE = started_a_dangerous_business_achievement
				#	VALUE = yes
				#}
				# EP1
				##1 Patronage
				add_achievement_global_variable_effect = {
					VARIABLE = started_patronage_achievement
					VALUE = yes
				}
				##2 Converging Paths
				add_achievement_global_variable_effect = {
					VARIABLE = started_converging_paths_achievement
					VALUE = yes
				}
				##3 Changing course
				add_achievement_global_variable_effect = {
					VARIABLE = started_changing_course_achievement
					VALUE = yes
				}
				##4 Hoarder
				add_achievement_global_variable_effect = {
					VARIABLE = started_hoarder_achievement
					VALUE = yes
				}
				##5 creme de la creme
				add_achievement_global_variable_effect = {
					VARIABLE = started_creme_de_la_creme_achievement
					VALUE = yes
				}
				##6 Give it back!
				add_achievement_global_variable_effect = {
					VARIABLE = started_polyglot_achievement
					VALUE = yes
				}
				##7 Inspirational
				add_achievement_global_variable_effect = {
					VARIABLE = started_inspirational_achievement
					VALUE = yes
				}
				##8 One of a Kind
				add_achievement_global_variable_effect = {
					VARIABLE = started_one_of_a_kind_achievement
						VALUE = yes
				}
				##9 True Tolerance
				add_achievement_global_variable_effect = {
					VARIABLE = started_true_tolerance_achievement
					VALUE = yes
				}
				##10 Delusions of Grandeur
				add_achievement_global_variable_effect = {
					VARIABLE = started_delusions_of_grandeur_achievement_achievement
					VALUE = yes
				}
				###11 Bod Chen Po
				#if = {
				#	limit = {
				#		this.dynasty = dynasty:105800
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_bod_chen_po_achievement
				#		VALUE = yes
				#	}
				#}
				###12 Turkish Eagle
				#if = {
				#	limit = {
				#		has_title = title:c_samosata
				#		this.house = house:house_seljuk # Seljuk
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_turkish_eagle_achievement
				#		VALUE = yes
				#	}
				#}
				###13 Rise of the Ghurids
				#if = {
				#	limit = {
				#		has_title = title:d_ghur
				#		this.dynasty = dynasty:791 #Ghurid
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_rise_of_the_ghurids_achievement
				#		VALUE = yes
				#	}
				#}
				###14 Brave and Bold
				#if = {
				#	limit = {
				#		game_start_date < 868.1.1
				#		this.dynasty = dynasty:699 #Piast
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_brave_and_bold_achievement
				#		VALUE = yes
				#	}
				#}
				###15 Lingua Franca
				add_achievement_global_variable_effect = {
					VARIABLE = started_lingua_franca_achievement
					VALUE = yes
				}
				###16 Beta Israel
				#add_achievement_global_variable_effect = {
				#	VARIABLE = started_beta_israel_achievement
				#	VALUE = yes
				#}
				## 17 They belong in a museum!
				add_achievement_global_variable_effect = {
					VARIABLE = started_they_belong_in_a_museum_achievement
					VALUE = yes
				}
				##18 I made this!
				add_achievement_global_variable_effect = {
					VARIABLE = started_i_made_this_achievement
					VALUE = yes
				}
				##19 Nobody Comes to Fika!
				#add_achievement_global_variable_effect = {
				#	VARIABLE = started_nobody_comes_to_fika_achievement
				#	VALUE = yes
				#}
				## 20 The True Royal Court
				add_achievement_global_variable_effect = {
					VARIABLE = started_the_true_royal_court_achievement
						VALUE = yes
				}
				# EP2
				## 01. The Grandest Tour
				add_achievement_global_variable_effect = {
					VARIABLE = started_the_grandest_tour_achievement
					VALUE = yes
				}
				## 02. Your Eternal Reward
				add_achievement_global_variable_effect = {
					VARIABLE = started_your_eternal_reward_achievement
					VALUE = yes
				}
				## 03. Imperial March
				add_achievement_global_variable_effect = {
					VARIABLE = started_imperial_march_achievement
					VALUE = yes
				}
				## 04. Black Dinner
				add_achievement_global_variable_effect = {
					VARIABLE = started_black_dinner_achievement
					VALUE = yes
				}
				## 05. There and Back Again
				add_achievement_global_variable_effect = {
					VARIABLE = started_there_and_back_again_achievement
					VALUE = yes
				}
				## 06. The Very Best
				add_achievement_global_variable_effect = {
					VARIABLE = started_the_very_best_achievement
					VALUE = yes
				}
				## 07. Like No One Ever Was
				add_achievement_global_variable_effect = {
					VARIABLE = started_like_no_one_ever_was_achievement
					VALUE = yes
				}
				## 08. A Thousand and One Night
				add_achievement_global_variable_effect = {
					VARIABLE = started_a_thousand_and_one_nights_achievement
					VALUE = yes
				}
				## 09. A Knight's Tale
				add_achievement_global_variable_effect = {
					VARIABLE = started_a_knights_tale_achievement
					VALUE = yes
				}
				## 10. Hunting Accident
				add_achievement_global_variable_effect = {
					VARIABLE = started_hunting_accident_achievement
					VALUE = yes
				}
				## 11. Lions and Tigers and Bears, Oh My!
				add_achievement_global_variable_effect = {
					VARIABLE = started_lions_and_tigers_and_bears_oh_my_achievement
					VALUE = yes
				}
				## 12. Fly, my Pretty!
				add_achievement_global_variable_effect = {
					VARIABLE = started_fly_my_pretty_achievement
					VALUE = yes
				}
				## 13. Pathway to Heaven
				add_achievement_global_variable_effect = {
					VARIABLE = started_pathway_to_heaven_achievement
					VALUE = yes
				}
				## 14. Sir Lance-a-Lot
				add_achievement_global_variable_effect = {
					VARIABLE = started_sir_lance_a_lot_achievement
					VALUE = yes
				}
				## 15. I'm in my Element(s)
				add_achievement_global_variable_effect = {
					VARIABLE = started_im_in_my_elements_achievement
					VALUE = yes
				}
				## 16. Ahab
				add_achievement_global_variable_effect = {
					VARIABLE = started_ahab_achievement
					VALUE = yes
				}
				## 17. Little William Marshal
				add_achievement_global_variable_effect = {
					VARIABLE = started_little_william_marshal_achievement
					VALUE = 0
				}
				add_achievement_global_variable_effect = {
					VARIABLE = little_william_marshal_achievement_tally
					VALUE = 0
				}
				## 18. A True & Perfect Knight
				add_achievement_global_variable_effect = {
					VARIABLE = started_a_true_and_perfect_knight_achievement
					VALUE = yes
				}
				### 19. A.E.I.O.U & Me
				#if = {
				#	limit = {
				#		# Etichonen, of whom the Hapsburgs are a cadet - we check dynasty rather than house so that an accidental cadet doesn't screw you.
				#		this.house ?= house:house_habsburg
				#	}
				#	add_achievement_global_variable_effect = {
				#		VARIABLE = started_a_e_i_o_u_and_me_achievement
				#		VALUE = yes
				#	}
				#}
				## 20. The Iron and Golden King
				add_achievement_global_variable_effect = {
					VARIABLE = started_the_iron_and_golden_king_achievement
					VALUE = yes
				}

				### RULER DESIGNER ACHIEVEMENT BLOCKS ###
				if = {
					limit = {
						num_virtuous_traits >= 3
					}
					add_achievement_flag_effect = { FLAG = rd_character_blocked_paragon_of_virtue_achievement_flag	}
				}
				if = {
					limit = {
						any_child = {
							count >= 10
							is_alive = yes
						}
					}
					add_achievement_flag_effect = { FLAG = rd_character_blocked_the_succession_is_safe_achievement_flag }
				}
				if = {
					limit = {
						any_child = {
							has_trait = inbred
						}
					}
					add_achievement_flag_effect = { FLAG = rd_character_blocked_keeping_it_in_the_family_achievement_flag }
				}
				if = {
					limit = {
						highest_held_title_tier >= tier_empire
						should_be_naked_trigger = yes
					}
					add_achievement_flag_effect = { FLAG = rd_character_blocked_the_emperors_new_clothes_achievement_flag }
				}
				#if = {
				#	limit = {
				#		is_from_ruler_designer = yes
				#		OR = {
				#			fp1_achievement_culture_norse_trigger = yes
				#			fp1_achievement_religious_norse_trigger = yes
				#		}
				#	}
				#	add_to_global_unavailable_achievements_list_effect = { FLAG = flag:rd_character_blocked_far_from_home_achievement }
				#	add_to_global_unavailable_achievements_list_effect = { FLAG = flag:rd_character_blocked_miklagardariki_achievement }
				#	add_to_global_unavailable_achievements_list_effect = { FLAG = flag:rd_character_blocked_faster_than_the_fox_achievement }
				#}
				if = {
					limit = {
						any_ruler = {
							is_from_ruler_designer = yes
						}
					}
					#add_to_global_unavailable_achievements_list_effect = { FLAG = flag:rd_character_blocked_iberia_or_iberia_achievement }
					#add_to_global_unavailable_achievements_list_effect = { FLAG = flag:rd_character_blocked_el_cid_achievement }
					add_achievement_global_variable_effect = {
						VARIABLE = any_ruler_designed_character_achievement
						VALUE = yes
					}
				}
			}
		}

		### ACHIEVEMENT: FROM RAGS TO RICHES TO RAGS TO RICHES 
		every_player = {
			limit = { highest_held_title_tier = tier_county }
			add_achievement_global_variable_effect = {
				VARIABLE = achievement_rags_to_riches_to_rags_to_riches_valid
				VALUE = yes
			}
		}

		
		#Set starting cultural acceptance
		# EK EDIT: cleared out vanilla ones, added some of our own. NOTE: these are bilateral, don't apply them both ways

		# values are intended to mostly make up for lack of good relations due to baseline factors. Cultures that should be very friendly but already share faith for example get reduced values therefore
		# I wanna reflect long historical coexistence, cousinship between separate heritages as well as "recent events" - Reins note

		## Akaviri
		culture:rimmen = {
			# +40
			# Rim-men have good relations with Anequinans and Rimmenese who accepted them
			change_cultural_acceptance = {
				target = culture:anequinan
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:rimmenese
				value = 40
				desc = cultural_acceptance_historical_relations
			}
		}
		culture:ilniviri = {
			# +30
			## The Ilniviri however have good relations with the Pellitinians
			change_cultural_acceptance = {
				target = culture:pellitinian
				value = 30
				desc = cultural_acceptance_historical_relations
			}
			# Also Mountain Orcs. The Potentates were very impressed with the loyalty and bravery of Orc Legionaires
			change_cultural_acceptance = {
				target = culture:mountain_orc
				value = 30
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Heartlanders and Nibenese make up the power base of the Potentate
			change_cultural_acceptance = {
				target = culture:heartlander
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:nibenese
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		## These progenitor Nedes would have good ties to Bretons
		culture:galen = {
			# +40
			change_cultural_acceptance = {
				target = culture:systrean
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:glenumbran
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:iliac
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:northmen
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:wrothgarian
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:bjoule
				value = 40
				desc = cultural_acceptance_historical_relations
			}
		}
		## Empire of Men: Cyrodiilics with others
		# Heartlanders
		culture:heartlander = {
			# +40
			# all bretons
			change_cultural_acceptance = {
				target = culture:systrean
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:glenumbran
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:iliac
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:northmen
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:wrothgarian
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:bjoule
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# mainland Nords
			change_cultural_acceptance = {
				target = culture:eastmarcher
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:westmarcher
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:cyro_nord
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +30
			# forebears - slightly reduced as they weren't as enthusiastic to the various Empires
			change_cultural_acceptance = {
				target = culture:forebear
				value = 30
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Scions: Ojel and Cyroboiche, somewhat lower
			change_cultural_acceptance = {
				target = culture:lukiul
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:cyrobosmer
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Colovians
		culture:colovian = {
			# +40
			# all bretons
			change_cultural_acceptance = {
				target = culture:systrean
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:glenumbran
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:iliac
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:northmen
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:wrothgarian
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:bjoule
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# mainland Nords
			change_cultural_acceptance = {
				target = culture:eastmarcher
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:westmarcher
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:cyro_nord
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +30
			# forebears - slightly reduced as they weren't as enthusiastic to the various Empires
			change_cultural_acceptance = {
				target = culture:forebear
				value = 30
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Scions: Ojel and Cyroboiche, somewhat lower
			change_cultural_acceptance = {
				target = culture:lukiul
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:cyrobosmer
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Nibenese
		culture:nibenese = {
			# +40
			# all bretons
			change_cultural_acceptance = {
				target = culture:systrean
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:glenumbran
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:iliac
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:northmen
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:wrothgarian
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:bjoule
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# mainland Nords
			change_cultural_acceptance = {
				target = culture:eastmarcher
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:westmarcher
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:cyro_nord
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +30
			# forebears - slightly reduced as they weren't as enthusiastic to the various Empires
			change_cultural_acceptance = {
				target = culture:forebear
				value = 30
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Scions: Ojel and Cyroboiche, somewhat lower
			change_cultural_acceptance = {
				target = culture:lukiul
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:cyrobosmer
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Strident
		culture:strident = {
			# +40
			# all bretons
			change_cultural_acceptance = {
				target = culture:systrean
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:glenumbran
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:iliac
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:northmen
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:wrothgarian
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:bjoule
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# mainland Nords
			change_cultural_acceptance = {
				target = culture:eastmarcher
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:westmarcher
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:cyro_nord
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# forebears - Strident get +40 compared to the +30 of other Cyrodiilics due to close proximity
			change_cultural_acceptance = {
				target = culture:forebear
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# Strident are additionally in good standing with Abeceans
			change_cultural_acceptance = {
				target = culture:abecean
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Scions: Ojel and Cyroboiche, somewhat lower
			change_cultural_acceptance = {
				target = culture:lukiul
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:cyrobosmer
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Nibenu - I guess these guys can get it too
		culture:blackwood = {
			# +40
			# all bretons
			change_cultural_acceptance = {
				target = culture:systrean
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:glenumbran
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:iliac
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:northmen
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:wrothgarian
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:bjoule
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# mainland Nords
			change_cultural_acceptance = {
				target = culture:eastmarcher
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:westmarcher
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:cyro_nord
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +30
			# forebears - slightly reduced as they weren't as enthusiastic to the various Empires
			change_cultural_acceptance = {
				target = culture:forebear
				value = 30
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Scions: Ojel and Cyroboiche
			change_cultural_acceptance = {
				target = culture:lukiul
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:cyrobosmer
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		## Yokudans
		# Silverhoof have intermarried with their neighbours in Tamriel since their arrival
		culture:silverhoof = {
			# +40
			# especially these guys who also like horsies
			change_cultural_acceptance = {
				target = culture:bjoule
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +30
			# the rest of Bretons
			change_cultural_acceptance = {
				target = culture:systrean
				value = 30
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:glenumbran
				value = 30
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:iliac
				value = 30
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:northmen
				value = 30
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:wrothgarian
				value = 30
				desc = cultural_acceptance_historical_relations
			}
		}
		## Altmer with others
		# Alinori
		culture:alinor = {
			# +40
			# Bosmer except Cyroboiche
			change_cultural_acceptance = {
				target = culture:bosmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:altmeribosmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:arenthi
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:silvenari
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:grahtwood
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# The Falmer - should they return
			change_cultural_acceptance = {
				target = culture:falmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
		}
		# Auridoni
		culture:auridon = {
			# +40
			# Bosmer except Cyroboiche
			change_cultural_acceptance = {
				target = culture:bosmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:altmeribosmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:arenthi
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:silvenari
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:grahtwood
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# The Falmer - should they return
			change_cultural_acceptance = {
				target = culture:falmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
		}
		# Balfieri - same as the others but also +20 with Bretons
		culture:balfiera = {
			# +40
			# Bosmer except Cyroboiche
			change_cultural_acceptance = {
				target = culture:bosmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:altmeribosmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:arenthi
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:silvenari
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:grahtwood
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# The Falmer - should they return
			change_cultural_acceptance = {
				target = culture:falmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# The Balfieri have coexisted alongside Bretons for millennia - more or less in peace
			change_cultural_acceptance = {
				target = culture:systrean
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:glenumbran
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:iliac
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:northmen
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:wrothgarian
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:bjoule
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Corelanya
		culture:corelanya = {
			# +40
			# Bosmer except Cyroboiche
			change_cultural_acceptance = {
				target = culture:bosmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:altmeribosmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:arenthi
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:silvenari
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:grahtwood
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# The Falmer - should they return
			change_cultural_acceptance = {
				target = culture:falmer
				value = 40
				desc = cultural_acceptance_historical_relations
			}
		}
		## Bosmer
		# Boiche
		culture:bosmer = {
			# +40
			# The Mathmeldi largely integrated into Bosmer society and were eventually fully absorbed
			change_cultural_acceptance = {
				target = culture:mathmeldi
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# The Imga have lived in Valenwood alongside the Bosmer since forever
			change_cultural_acceptance = {
				target = culture:imga
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Bosmer, as distant cousins, have a somewhat decent relationship with Khajiit - when they aren't busy killing each other that is (looking at you, Arenthi)
			change_cultural_acceptance = {
				target = culture:pellitinian
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:anequinan
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:baandari
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:malapiit
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			# Wood Orcs also make their home in Valenwood, and sometimes trade with the Bosmer
			change_cultural_acceptance = {
				target = culture:wood_orc
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Salaboiche
		culture:altmeribosmer = {
			# +40
			# The Mathmeldi largely integrated into Bosmer society and were eventually fully absorbed
			change_cultural_acceptance = {
				target = culture:mathmeldi
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# The Imga have lived in Valenwood alongside the Bosmer since forever
			change_cultural_acceptance = {
				target = culture:imga
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Bosmer, as distant cousins, have a somewhat decent relationship with Khajiit - when they aren't busy killing each other that is (looking at you, Arenthi)
			change_cultural_acceptance = {
				target = culture:pellitinian
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:anequinan
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:baandari
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:malapiit
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			# Wood Orcs also make their home in Valenwood, and sometimes trade with the Bosmer
			change_cultural_acceptance = {
				target = culture:wood_orc
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Cyroboiche
		culture:cyrobosmer = {
			# +40
			# The Mathmeldi largely integrated into Bosmer society and were eventually fully absorbed
			change_cultural_acceptance = {
				target = culture:mathmeldi
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# The Imga have lived in Valenwood alongside the Bosmer since forever
			change_cultural_acceptance = {
				target = culture:imga
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Bosmer, as distant cousins, have a somewhat decent relationship with Khajiit - when they aren't busy killing each other that is (looking at you, Arenthi)
			change_cultural_acceptance = {
				target = culture:pellitinian
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:anequinan
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:baandari
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:malapiit
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			# Wood Orcs also make their home in Valenwood, and sometimes trade with the Bosmer
			change_cultural_acceptance = {
				target = culture:wood_orc
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Silvenari
		culture:silvenari = {
			# +40
			# The Mathmeldi largely integrated into Bosmer society and were eventually fully absorbed
			change_cultural_acceptance = {
				target = culture:mathmeldi
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# The Imga have lived in Valenwood alongside the Bosmer since forever
			change_cultural_acceptance = {
				target = culture:imga
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Bosmer, as distant cousins, have a somewhat decent relationship with Khajiit - when they aren't busy killing each other that is (looking at you, Arenthi)
			change_cultural_acceptance = {
				target = culture:pellitinian
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:anequinan
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:baandari
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:malapiit
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			# Wood Orcs also make their home in Valenwood, and sometimes trade with the Bosmer
			change_cultural_acceptance = {
				target = culture:wood_orc
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Etarani
		culture:grahtwood = {
			# +40
			# The Mathmeldi largely integrated into Bosmer society and were eventually fully absorbed
			change_cultural_acceptance = {
				target = culture:mathmeldi
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# The Imga have lived in Valenwood alongside the Bosmer since forever
			change_cultural_acceptance = {
				target = culture:imga
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Bosmer, as distant cousins, have a somewhat decent relationship with Khajiit - when they aren't busy killing each other that is (looking at you, Arenthi)
			change_cultural_acceptance = {
				target = culture:pellitinian
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:anequinan
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:baandari
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:malapiit
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			# Wood Orcs also make their home in Valenwood, and sometimes trade with the Bosmer
			change_cultural_acceptance = {
				target = culture:wood_orc
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Arenthi - these guys aren't very friendly with Khajiit
		culture:arenthi = {
			# +40
			# The Mathmeldi largely integrated into Bosmer society and were eventually fully absorbed
			change_cultural_acceptance = {
				target = culture:mathmeldi
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# The Imga have lived in Valenwood alongside the Bosmer since forever
			change_cultural_acceptance = {
				target = culture:imga
				value = 40
				desc = cultural_acceptance_historical_relations
			}
			# +20
			# Wood Orcs also make their home in Valenwood, and sometimes trade with the Bosmer
			change_cultural_acceptance = {
				target = culture:wood_orc
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		## Cantemirics
		culture:cantemiric = {
			# +20
			# While distant cousins now, the Cantemirics nurture some respect with the Dunmer - except those of Great House Dres who are rivals
			change_cultural_acceptance = {
				target = culture:gah_julan
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			# The Imga have lived in Valenwood alongside the Bosmer since forever
			change_cultural_acceptance = {
				target = culture:armun_an
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			# +20
			change_cultural_acceptance = {
				target = culture:chuzei
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:chi_addun
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:ashlander
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		## Orcs
		# Mountain Orc
		culture:mountain_orc = {
			# +20
			# Orcs get the Pariah baseline bonus with other goblinken, but let's give them a little more on top
			change_cultural_acceptance = {
				target = culture:goblin
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:riekling
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:riekr
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			# Mountain Orcs also have some dealings with the Reachfolk. one of the few peoples in TES who do not actively persecute them for being Pariah
			change_cultural_acceptance = {
				target = culture:reachfolk
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Iron Orc
		culture:iron_orc = {
			# +20
			# Orcs get the Pariah baseline bonus with other goblinken, but let's give them a little more on top
			change_cultural_acceptance = {
				target = culture:goblin
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:riekling
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:riekr
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		# Wood Orc
		culture:wood_orc = {
			# +20
			# Orcs get the Pariah baseline bonus with other goblinken, but let's give them a little more on top
			change_cultural_acceptance = {
				target = culture:goblin
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:riekling
				value = 20
				desc = cultural_acceptance_historical_relations
			}
			change_cultural_acceptance = {
				target = culture:riekr
				value = 20
				desc = cultural_acceptance_historical_relations
			}
		}
		### EK EDIT: The hell is an HRE?!
		# Custom ruler under the HRE should have lowered feudal obligations
		# if = {
			# limit = { exists = title:e_hre.holder }
			# title:e_hre.holder = {
				# every_vassal = {
					# limit = {
						# is_ai = no
						# vassal_contract_has_modifiable_obligations = yes
					# }
					# vassal_contract_decrease_obligation_level = feudal_government_taxes
					# vassal_contract_decrease_obligation_level = feudal_government_levies
					# set_vassal_contract_modification_blocked = no
				# }
			# }
		# }
		### CE1 LEGITIMACY SETUP ###
		every_ruler = {
			limit = {
				has_legitimacy = yes
			}
			add_legitimacy = base_legitimacy_value
		}

		#EK DISABLED: Vanilla historical characters. we could take a look at their events for our own narrative stuff tho
		#if = { # Special historical events for Matilda!
		#	limit = {
		#		character:7757 ?= { is_alive = yes }
		#	}
		#	character:7757 ?= {
		#		trigger_event = bookmark.1066 # Matildas marriage to her step-brother, with plausible historical options!
		#		trigger_event = { # Matildas suspected witchcraft, the player decides if its true or not!
		#			id = bookmark.1067
		#			years = { 1 5 }
		#		}
		#	}
		#}
		#if = { # Special historical events for Vratislav!
		#	limit = {
		#		character:522 ?= { is_alive = yes }
		#	}
		#	character:522 ?= {
		#		trigger_event = { # Vratislav and the Slavic Marches, he didn't historically get them (one briefly, but eh). The player chooses to appease the emperor or go after the coveted lands themselves!
		#			id = bookmark.1068
		#			days = { 35 120 }
		#		}
		#		trigger_event = { # Jaromir, Vratislav's brother, was a pain - this event is an opportunity for the player to handle the rivalry
		#			id = bookmark.1069
		#			days = { 1 29 }
		#		}
		#	}
		#}
		#if = { # Special historical events for Robert the Fox!
		#	limit = {
		#		character:1128 ?= { is_alive = yes }
		#	}
		#	character:1128 ?= {
		#		trigger_event = { # A Norman Sicily - Robert historically conquered quite a bit here, the player can choose how far they want to go and the risk they want to take. The more risk, the more event troops/claims.
		#			id = bookmark.1070
		#			days = { 35 120 }
		#		}
		#		trigger_event = { # The Pretender Monk - Raiktor is a historical character, a monk wo pretended to be a deposed Byzantine emperor which Robert used to beat up Byzantium. Here you can follow historical conquests (taking a bit of the coast) or go full on 'install him as emperor for real'-mode!
		#			id = bookmark.1071
		#			years = { 1 7 }
		#		}
		#	}
		#}
		#if = { # Special historical events for Emir Yahya!
		#	limit = {
		#		character:3924 ?= { is_alive = yes }
		#	}
		#	character:3924 ?= {
		#		trigger_event = { # Conquering Cordoba - Gain an opportunity to conquer Cordoba while gaining one of two buffs; one intrigue-focused, and one military. Historically he was poisoned after having conquered the city... but that's no fun for the player!
		#			id = bookmark.1072
		#			days = { 10 35 }
		#		}
		#	}
		#}
		### EP3 SETUP ###
		if = {
			limit = { has_ep3_dlc_trigger = yes }
			### EP3 LAAMP SETUP ###
			# Resources.
			every_independent_ruler = {
				limit = { is_landless_adventurer = yes }
				# Cash.
				add_gold = {
					value = {
						value = 0
						add = prestige
						add = piety
						divide = 10
					}
				}
				save_temporary_scope_as = adventurer_scope
				# Set CoA
				if = {	#EK EDIT: Allows for exceptions where we don't want laamps to share CoA with their leader's house
					limit = {
						NOR = {
							has_title = title:d_dusksabers
							has_title = title:d_laamp_young_pilots
							has_title = title:d_laamp_south_argonia
							has_title = title:d_laamp_ayleid_chroniclers
							has_title = title:d_laamp_wayward_column
							has_title = title:d_laamp_battlelords
						}
					}
					primary_title = { set_coa = scope:adventurer_scope.house }
				}	#EK EDIT END
				# Cleanup characters
				every_councillor = {
					if = {
						limit = {
							NOR = {
								has_council_position = councillor_court_chaplain
								has_council_position = councillor_spouse
							}
						}
						scope:adventurer_scope = {
							fire_councillor = prev
						}
						remove_opinion = {
							modifier = fired_from_council_opinion
							target = scope:adventurer_scope
						}
					}
					else_if = {
						limit = {
							NOR = {
								is_close_or_extended_family_of = prev
								has_relation_lover = prev
								has_relation_friend = prev
								is_consort_of = prev
								has_council_position = councillor_spouse
							}
						}
						death = {
							death_reason = death_vanished
						}
					}
				}
				# Evict everyone who isn't your family from your camp.
				every_courtier = {
					limit = {
						prev = { save_temporary_scope_as = char_temp }
						NOR = {
							dynasty ?= scope:char_temp.dynasty
							is_imprisoned_by = scope:char_temp
							# Plus any relations, who are presumably meant to be here.
							has_important_relationship_with_character_trigger = { CHARACTER = scope:char_temp }
							# Catch bastards and such that may be left over.
							is_close_or_extended_family_of = scope:char_temp
						}
					}
					move_to_pool = yes
				}
				# Courtiers.
				#trigger_event = ep3_laamps.1001
				# EK EDIT: if you're using RD to start as a revivable dead culture, we trigger this event later
				if = {
					limit = {
						NOR = {
							culture = culture:falmer
							culture = culture:falmer_betrayed
							culture = culture:amz_kagren
							culture = culture:amz_vtharden
							culture = culture:amz_vtholften
							culture = culture:atmoran
						}
					}
					trigger_event = ep3_laamps.1001
				}
			}
			# Starting camp purposes.
			#EK NOTE: kept Hereweard as example
			## Hereweard the Wake
			#character:90028 ?= {
			#if = {
			#	limit = { is_alive = yes }
			#		add_realm_law_skip_effects = camp_purpose_brigands
			#	}
			# Setup event for his story
			#	trigger_event = {
			#		id = ep3_laamps.5999
			#		days = { 1 2 }
			#	}
			#}
			every_independent_ruler = {
				limit = { is_landless_adventurer = yes }
				# C... food.
				domicile = { change_provisions = starting_provisions_value }
				# Contracts
				if = {
					limit = { is_ai = no }
					# Set up additional firing contracts.
					player_adventurer_contract_generation_on_wait_in_place_effect = yes
					#generate contracts if you are far away from your previous location
					player_adventurer_contract_generation_on_domicile_moved_effect = yes
				}
				else = {
					create_story = { type = story_adventurer_ai }
					trigger_event = {
						on_action = on_adventurer_ai_new_employer_arrival
						days = { 10 30 }
					}
				}
				# Sort our starting flavourisation.
				if = {
					limit = { has_realm_law = camp_purpose_mercenaries }
					set_variable = flavourise_camp_purpose_mercenaries
				}
				else_if = {
					limit = { has_realm_law = camp_purpose_wanderers }
					set_variable = flavourise_camp_purpose_wanderers
				}
				else_if = {
					limit = { has_realm_law = camp_purpose_scholars }
					set_variable = flavourise_camp_purpose_scholars
				}
				else_if = {
					limit = { has_realm_law = camp_purpose_explorers }
					set_variable = flavourise_camp_purpose_explorers
				}
				else_if = {
					limit = { has_realm_law = camp_purpose_brigands }
					set_variable = flavourise_camp_purpose_brigands
				}
				else_if = {
					limit = { has_realm_law = camp_purpose_legitimists }
					set_variable = flavourise_camp_purpose_legitimists
				}
				# And tally our numbers for performance purposes.
				add_to_global_variable_list = {
					name = laamps_tally
					target = this.primary_title
				}
			}
			### EP3 ADMIN SETUP ###
			every_independent_ruler = {
				limit = { government_allows = administrative }
				save_scope_as = top_liege
				### EP3 NOBLE FAMILIES & DOMICILE SETUP ###
				random_held_title = { # May be removed once every_noble_family includes liege (TIT-51212)
					limit = { is_noble_family_title = yes }
					set_coa = scope:top_liege.house
				}
				every_noble_family = {
					# Ensure Noble Family CoA match House
					set_coa = holder.house
					# Ensure holders of historical noble family titles are the default house heads
					holder ?= {
						save_scope_as = nf_holder
						if = {
							limit = { is_landed = yes }
							capital_province = { save_scope_as = domicile_location }
						}
						# TODO_CD_EP3: remove once TIT-51212 is resolved and confirmed
						house ?= {
							if = {
								limit = { house_head != scope:nf_holder }
								set_house_head = scope:nf_holder
							}
						}
					}
					set_color_from_title = scope:nf_holder.capital_county
				}
			}
		}
		#EK DISABLED
		# Byzantium naming
		#title:e_byzantium = {
		#	if = {
		#		limit = {
		#			has_game_rule = eastern_rome_name_of_byzantium
		#		}
		#		set_title_name = e_eastern_roman_empire
		#	}
		#	else_if = {
		#		limit = {
		#			has_game_rule = roman_empire_name_of_byzantium
		#		}
		#		set_title_name = e_roman_empire
		#	}
		#	else_if = {
		#		limit = {
		#			has_game_rule = romania_name_of_byzantium
		#		}
		#		set_title_name = e_romania_empire
		#	}
		#	else_if = {
		#		limit = {
		#			has_game_rule = empire_of_the_greeks_name_of_byzantium
		#		}
		#		set_title_name = e_empire_of_the_greeks
		#	}
		#	else_if = {
		#		limit = {
		#			has_game_rule = rhomaion_name_of_byzantium
		#		}
		#		set_title_name = e_rhomaion
		#	}
		#	else_if = {
		#		limit = {
		#			has_game_rule = unholy_roman_empire_name_of_byzantium
		#		}
		#		set_title_name = e_unholy_roman_empire
		#	}
		#}
		#EK EDIT: changed Sahara into Alikr
		# Saharan stuff.
		every_county_in_region = {
			region = mundus_tamriel_hammerfell_alikr_desert
			# Every county is in the region, not every province of every county, so we go to county to avoid iterating over every world province _then_ check which ones are in the region.
			every_county_province = { apply_saharan_provisions_debuff_effect = yes }
		}
		#EK TODO: plug in our values appropriate for our bookmarks
		# 440/450 Buildings
		if = {
			limit = {
				game_start_date >= 3360.1.1 #EK EDIT - was 1066
				game_start_date < 3371.10.1 #EK EDIT - was 1178
			}
			every_province = {
				limit = {
					has_holding = yes
				}
				generate_building = yes
				brewery_counter_start_effect = yes
			}
			every_domicile = {
				if = {
					limit = {
						is_domicile_type = estate
						exists = owner
					}
					if = {
						limit = {
							NOT = { has_domicile_building_or_higher = estate_main_02 }
							owner.culture ?= { has_innovation = innovation_city_planning }
						}
						add_domicile_building = estate_main_02
						add_random_internal_estate_building = yes
					}

					fill_external_estate_building_effect = yes
				}
			}
		}
		# Post-450 Buildings
		else_if = {
			limit = {
				game_start_date >= 3371.10.1 #EK TODO: change to something else when we get more bookmarks
			}
			every_province = {
				limit = {
					has_holding = yes
				}
				generate_building = yes
				generate_building = yes
				generate_building = yes
				generate_building = yes
				generate_building = yes
				generate_building = yes
				if = {
					limit = {
						county.development_level >= 8
					}
					generate_building = yes
					generate_building = yes
				}
				if = {
					limit = {
						county.development_level >= 10
					}
					generate_building = yes
				}
				if = {
					limit = {
						county.development_level >= 12
					}
					generate_building = yes
				}
				if = {
					limit = {
						county.development_level >= 14
					}
					generate_building = yes
					generate_building = yes
				}
				if = {
					limit = {
						county.development_level >= 16
					}
					generate_building = yes
				}
				if = {
					limit = {
						county.development_level >= 18
					}
					generate_building = yes
				}
				if = {
					limit = {
						county.development_level >= 20
					}
					generate_building = yes
				}
				if = {
					limit = {
						county.development_level >= 25
					}
					generate_building = yes
					generate_building = yes
					generate_building = yes
				}
				brewery_counter_start_effect = yes
			}
			every_domicile = {
				#if = { # Left in if we want adventurers to spawn with stuff
				#	limit = {
				#		is_domicile_type = camp
				#	}
				#	add_domicile_building = camp_main_02
				#	add_domicile_building = camp_main_03
				#	random_list = {
				#		10 = {
				#			add_domicile_building = supply_tent_01
				#			add_domicile_building = supply_tent_02
				#			random_list = {
				#				10 = {
				#					add_domicile_building = supply_tent_sutler
				#				}
				#				10 = {
				#					add_domicile_building = supply_tent_mender
				#				}
				#				10 = {
				#					add_domicile_building = supply_tent_smithy
				#				}
				#				10 = {
				#					add_domicile_building = supply_tent_arsenal
				#				}
				#			}
				#		}
				#		10 = {
				#			add_domicile_building = barber_tent_01
				#			add_domicile_building = barber_tent_02
				#			random_list = {
				#				10 = {
				#					add_domicile_building = barber_tent_surgeons_tools
				#				}
				#				10 = {
				#					add_domicile_building = barber_tent_dentists_tools
				#				}
				#				10 = {
				#					add_domicile_building = barber_tent_torturers_tools
				#				}
				#			}
				#		}
				#		10 = {
				#			add_domicile_building = baggage_train_01
				#			add_domicile_building = baggage_train_02
				#			random_list = {
				#				10 = {
				#					add_domicile_building = baggage_train_ample_steeds
				#				}
				#				10 = {
				#					add_domicile_building = baggage_train_porters
				#				}
				#				10 = {
				#					add_domicile_building = baggage_train_trackers
				#				}
				#				10 = {
				#					add_domicile_building = baggage_train_kennel
				#				}
				#			}
				#		}
				#	}
				#	random_list = {
				#		10 = {
				#			add_domicile_building = mess_tent_01
				#			add_domicile_building = mess_tent_02
				#			random_list = {
				#				10 = {
				#					add_domicile_building = mess_tent_herbalists
				#				}
				#				10 = {
				#					add_domicile_building = mess_tent_brewers
				#				}
				#				10 = {
				#					add_domicile_building = mess_tent_curers
				#				}
				#				10 = {
				#					add_domicile_building = mess_tent_bakers
				#				}
				#				10 = {
				#					add_domicile_building = mess_tent_cooks
				#				}
				#			}
				#		}
				#		10 = {
				#			add_domicile_building = camp_fire_01
				#			add_domicile_building = camp_fire_02
				#			random_list = {
				#				10 = {
				#					add_domicile_building = camp_fire_trailing_musicians
				#				}
				#				10 = {
				#					add_domicile_building = camp_fire_wandering_poets
				#				}
				#				10 = {
				#					add_domicile_building = camp_fire_capering_fools
				#				}
				#				10 = {
				#					add_domicile_building = camp_fire_libations_for_the_lost
				#				}
				#			}
				#		}
				#	}
				#	random_list = {
				#		10 = {
				#			add_domicile_building = camp_perimeter_01
				#			add_domicile_building = camp_perimeter_02
				#			random_list = {
				#				10 = {
				#					add_domicile_building = camp_perimeter_good_siting
				#				}
				#				10 = {
				#					add_domicile_building = camp_perimeter_fixed_layout
				#				}
				#			}
				#		}
				#		10 = {
				#			add_domicile_building = proving_grounds_01
				#			add_domicile_building = proving_grounds_02
				#		}
				#	}
				#}
				if = {
					limit = {
						is_domicile_type = estate
						exists = owner
					}
					if = {
						limit = {
							NOT = { has_domicile_building_or_higher = estate_main_02 }
							owner.culture ?= { has_innovation = innovation_city_planning }
						}
						add_domicile_building = estate_main_02
						add_random_internal_estate_building = yes
					}
					if = {
						limit = {
							has_domicile_building = estate_main_02
							NOT = { has_domicile_building_or_higher = estate_main_03 }
							owner.culture ?= { has_innovation = innovation_manorialism }
						}
						add_domicile_building = estate_main_03
						while = {
							count = 2
							add_random_internal_estate_building = yes
						}
					}

					fill_external_estate_building_effect = yes
				}
			}
		}
		# Purge family titles if Admin isn't enabled
		if = {
			limit = {
				NOT = { has_dlc_feature = roads_to_power }
			}
			every_ruler = {
				save_temporary_scope_as = this_ruler
				every_held_title = {
					limit = {
						has_title_law = noble_family_succession_law
					}
					scope:this_ruler = {
						destroy_title = prev
					}
				}
			}
		}

		every_county_in_region = {
			region = world_steppe
			limit = {
				uses_county_fertility = yes
			}

			if = {
				limit = {
					holder = {
						government_has_flag = government_is_nomadic
					}
					county_fertility > 20
					county_fertility <= 90
				}
				switch = {
					trigger = holder.primary_title.tier
					tier_empire = {
						change_county_fertility = { 16 32 }
					}
					tier_kingdom = {
						change_county_fertility = { 12 16 }
					}
					tier_duchy = {
						change_county_fertility = { 8 12 }
					}
					tier_county = {
						change_county_fertility = { 2 8 }
					}
				}
			}
			else_if = {
				limit = {
					holder = {
						government_has_flag = government_is_herder
					}
				}
				change_county_fertility = { 44 64 }
 			}
		}

		# Conquerors
		#character:144133 ?= {
		#	if = {
		#		limit = {
		#			is_alive = yes
		#			NOT = { has_game_rule = no_conquerors_frequency }
		#		}
		#		create_story = story_conqueror
		#	}
		#}
		#character:144141 ?= {
		#	if = {
		#		limit = {
		#			is_alive = yes
		#			NOT = { has_game_rule = no_conquerors_frequency }
		#		}
		#		create_story = story_conqueror
		#	}
		#}
		#character:175080 ?= {
		#	if = {
		#		limit = {
		#			is_alive = yes
		#			NOT = { has_game_rule = no_conquerors_frequency }
		#		}
		#		create_story = story_conqueror
		#	}
		#}
		#character:226000 ?= {
		#	if = {
		#		limit = {
		#			is_alive = yes
		#			NOT = { has_game_rule = no_conquerors_frequency }
		#		}
		#		create_story = story_conqueror
		#	}
		#}
		
		every_player = {
			limit = {
				is_landed = yes
			}
			while = {
				count = 7
				limit = {
					any_courtier = {
						count < 7
						is_adult = yes
					}
				}
				save_scope_as = player_scope
				random_list = {
					1 = {
						create_character = {
							employer = scope:player_scope
							age = { 20 30 }
							random_traits = yes
							gender_female_chance = scope:player_scope.marriage_gender_adjusted_female_chance
							culture = scope:player_scope.culture
							faith = scope:player_scope.faith
							after_creation = {
								ek_character_setup_effect = yes
							
								random_list = {
									200 = {
										# Character is of average weight, nothing happens	
									}
									25 = {
										change_current_weight = -25
									}
									25 = {
										change_current_weight = -75
									}
									25 = {
										change_current_weight = 25
									}
									25 = {
										change_current_weight = 75
									}
									5 = {
										change_current_weight = 150
									}
								}
							}
						}
					}
					4 = {
						create_character = {
							employer = scope:player_scope
							age = { 20 40 }
							random_traits = yes
							gender_female_chance = 15
							culture = scope:player_scope.culture
							faith = scope:player_scope.faith
							after_creation = {
								ek_character_setup_effect = yes
							
								random_list = {
									200 = {
										# Character is of average weight, nothing happens	
									}
									25 = {
										change_current_weight = -25
									}
									25 = {
										change_current_weight = -75
									}
									25 = {
										change_current_weight = 25
									}
									25 = {
										change_current_weight = 75
									}
									5 = {
										change_current_weight = 150
									}
								}
							}
						}
					}
				}
			}
		}

		# Sanity check the setup if in debug mode
		if = {
        	limit = {
        		debug_only = yes
        	}
	        run_setup_tests_effect = yes
    	}
		set_global_variable = game_has_started
	}

	events = {
		#EK ADDITION
		ek_holy_orders.1
		ek_holy_orders.2
		#EK ADDITION END
		game_rule.1000	#Autopopulate families.
		# game_rule.1011	#Hungarian Migration management.
		historical_artifacts.0023			# Historical Artifacts Generator
	}
}

#$CHARACTER$.house = {
#			save_scope_as = character_house
#
#			add_unity_value = {
#				value = {
#					value = $VALUE$
#					if = { # House heads have a larger impact on unity
#						limit = { house_head = $CHARACTER$ }
#						multiply = unity_house_head_multiplier_value
#					}
#				}
#				character = $CHARACTER$
#				desc = $DESC$
#			}
#		}

