decisions = {

	hold_a_epic_tournament  = {
		only_independent = yes
		is_high_prio = yes
		ai_check_interval = 24
		
		potential = {
			NOT = { culture = wilderness }
			NOR = {
				has_character_modifier = epic_tournament
				has_character_flag = epic_tournament
			}
			independent = yes
			NOT = { is_nomadic = yes }
			OR = {
				gender_equality_trigger = yes
				NOT = { is_female = yes	}
			}
			OR = {
				tier = king
				tier = emperor 
			}
			location = {
				owner = { character = ROOT }
			}
			NOT = {
				trait = dryad_race
				trait = elf_race
			}
		}
		allow = {
			war = no
			prisoner = no
			in_command = no
			NOT = { is_inaccessible_trigger = yes }
			age = 15
			prestige = 500
			wealth = 200
			custom_tooltip = {
				text = is_not_busy_trigger_tooltip
				hidden_tooltip = { NOT = { has_character_flag = do_not_disturb } }
			}
		}
		effect = {
			add_character_modifier = {
				name = epic_tournament
				years = 100
				hidden = yes
			}
			set_character_flag = do_not_disturb
			clr_character_flag = tournament_has_ended
			hidden_tooltip = { character_event = { id = 70999 days = 300 } } # Safety catch flag clearing
			wealth = -200
			prestige = 100
			character_event = { id = 70033 tooltip = "tournament_invite" }
			hidden_tooltip = {
				clr_character_flag = tournament_has_ended
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = {
					OR = {
						wealth = 1000
						scaled_wealth = 3.0
					}
				}
			}
		}
	}
	
	# buy_indulgence_for_sins = {

	# issue_declaration_of_repentance = {
	
	demand_liege_title = {
		only_playable = yes
		is_high_prio = yes
		potential = {
			AND = {
				ai = no
				is_playable = yes
			}
			NOT = { culture = wilderness }
			has_ambition = obj_gain_any_title
			liege = {
				NOT = { character = ROOT }
			}
			is_adult = yes
			prisoner = no
			NOT = { trait = incapable }
		}
		allow = {
			prestige = 60
			liege = {
				has_regent = no
				NOT = { has_opinion_modifier = { who = ROOT modifier = requested_land } }
				demesne_size = 3
				any_demesne_title = {
					can_be_given_away = yes
					tier = COUNT
					NOT = { location = { is_capital = yes } }
				}
			}
		}
		effect = {
			prestige = -60
			liege = {
				opinion = {
					who = ROOT
					years = 2
					modifier = requested_land
				}
				random_demesne_title = {
					limit = {
						can_be_given_away = yes
						tier = COUNT
						NOT = { location = { is_capital = yes } }
					}
					save_event_target_as = vassal_wanted_title
				}
			}
			custom_tooltip = {
				text = demand_liege_title_tooltip
				hidden_tooltip = { liege = { letter_event = { id = 63041 days = 4 } } } # "vassal_request_events.txt"
			}
		}
		ai_will_do = {
			factor = 0 # The AI is limited to the similar event 63040
		}
	}
	
	# sadaqah_saddka

	# hold_a_furusiyya = {
	
	# restore_roman_empire = {
	
	# mend_great_schism = {
	
	# claim_constantinople = {
	
	# make_rome_capital = {
	
	petition_doge_for_tp = {
		only_playable = yes
		is_high_prio = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			NOT = { culture = wilderness }
			is_merchant_republic = no
			is_patrician = yes
			liege = { is_merchant_republic = yes }
			NOT = { has_character_flag = petition_doge_for_tp_taken }
			OR = {
				liege = {
					any_vassal = {
						is_patrician = yes
						num_of_trade_post_diff = {
							character = ROOT
							value = 10
						}
					}
				}
				AND = {
					NOT = { num_of_trade_posts = 1 }
					liege = {
						any_vassal = {
							is_patrician = yes
							num_of_trade_posts = 10
						}
					}
				}
			}
		}
		allow = {
			liege = {
				opinion = {
					who = ROOT
					value = 25
				}
			}
		}
		effect = {
			set_character_flag = petition_doge_for_tp_taken
			liege = {
				letter_event = { id = REP.500 days = 5 tooltip = EVTTOOLTIP_REP_500 }
			}
		}
		ai_will_do = {
			factor = 1
		}
	}
	
	usurp_tp = {
		only_playable = yes
		is_high_prio = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			NOT = { culture = wilderness }
			is_merchant_republic = yes
			is_patrician = yes
			NOT = { has_character_flag = usurp_tp_taken }
			OR = {
				any_vassal = {
					is_patrician = yes
					num_of_trade_post_diff = {
						character = ROOT
						value = 10
					}
				}
				AND = {
					NOT = { num_of_trade_posts = 1 }
					any_vassal = {
						is_patrician = yes
						num_of_trade_posts = 10
					}
				}
			}
		}
		allow = {
			is_merchant_republic = yes
		}
		effect = {
			set_character_flag = usurp_tp_taken
			if = {
				limit = {
					num_of_trade_posts = 1
					any_vassal = {
						is_patrician = yes
						num_of_trade_post_diff = {
							character = ROOT
							value = 10
						}
					}
				}
				random_vassal = {
					limit = {
						is_patrician = yes
						num_of_trade_post_diff = {
							character = ROOT
							value = 10
						}
					}
					set_character_flag = target_patrician_doge
					letter_event = { id = REP.510 days = 5 tooltip = EVTTOOLTIP_REP_510 }
				}
			}
			if = {
				limit = {
					NOT = { num_of_trade_posts = 1 }
					any_vassal = {
						is_patrician = yes
						num_of_trade_posts = 10
					}
				}
				random_vassal = {
					limit = {
						is_patrician = yes
						num_of_trade_posts = 10
					}
					set_character_flag = target_patrician_doge
					letter_event = { id = REP.510 days = 5 tooltip = EVTTOOLTIP_REP_510 }
				}
			}
		}
		ai_will_do = {
			factor = 1
		}
	}
	
	# organize_varangian_guard = {
	
	# create_hungary = {
	
	# become_saoshyant = {
	
	# create_leon = {
	
	# create_castille = {
	
	# create_portugal = {
	
	# restore_priesthood = {
	
	# build_third_temple = {
	
	# restore_high_priesthood = {
	
	# create_israel = {
	
	# welcome_jews = {
	
	# expel_jews = {
	
	# embrace_mutazila = {
	
	# embrace_ashari = {
	
	# become_samrat_chakravartin = {
	
	# form_the_hre = {
	
	# form_the_hre_early = {
	
	form_new_kingdom = {
		only_independent = yes
		is_high_prio = yes
		ai_check_interval = 24
		
		potential = {
			is_playable = yes
			tier = DUKE
			NOT = { tier = KING }
			
			OR = {
				has_dlc = "Charlemagne"
				AND = {
					is_alternate_start = yes
					has_alternate_start_parameter = {
						key = dejure_kingdoms
						value = none
					}
				}
			}
			
			holy_order = no
			
			NOT = {
				has_game_rule = {
					name = dynamic_realms
					value = off
				}
			}
			
			OR = {
				ai = no
				AND = {
					trait = proud
					prestige = 5000
				}
				AND = {
					trait = ambitious
					prestige = 5000
				}
				AND = {
					realm_size = 70
					any_demesne_title = {
						count = 4
						tier = DUKE
					}
				}
				prestige = 15000
				AND = {
					is_alternate_start = yes
					has_alternate_start_parameter = {
						key = dejure_kingdoms
						value = none
					}
				}
			}
		}
		allow = {
			is_adult = yes
			prisoner = no
			NOT = { trait = incapable }
			independent = yes
			
			conditional_tooltip = {
				trigger = {
					AND = {
						is_alternate_start = yes
						has_alternate_start_parameter = {
							key = dejure_kingdoms
							value = none
						}
					}
				}
				prestige = 250
				wealth = 50
			}
			
			conditional_tooltip = {
				trigger = {
					NOT = {
						is_alternate_start = yes
						has_alternate_start_parameter = {
							key = dejure_kingdoms
							value = none
						}
					}
				}
				prestige = 1000
				wealth = 300
			}

			OR = {
				realm_size = 35
				custom_tooltip = {
					text = form_new_kingdom_requirement_tooltip
					hidden_tooltip = {
						any_demesne_title = {
							count = 3
							tier = DUKE
						}
					}
				}
			}
		}
		effect = {
			primary_title = {
				create_title = {
					tier = KING
					landless = no
					temporary = no
					custom_created = yes
					culture = ROOT
					holder = ROOT
					base_title = THIS
					copy_title_laws = yes
				}

				new_title = {
					copy_title_history = PREV
				}

				hidden_tooltip = {
					empire = {
						ROOT = {
							primary_title = {
								de_jure_liege = PREVPREV
							}
						}
					}

					ROOT = {
						primary_title = {
							holder_scope = {
								any_title_under = {
									limit = {
										tier = DUKE
										kingdom = {
											has_holder = no
										}
									}
									de_jure_liege = PREVPREV
								}
								if = {
									limit = {
										has_alternate_start_parameter = {
											key = dejure_kingdoms
											value = none
										}
									}
									any_title_under = {
										limit = {
											tier = DUKE
										}
										de_jure_liege = PREVPREV
									}
								}
								any_title_under = {
									limit = {
										tier = COUNT
										location = {
											duchy = {
												kingdom = {
													has_holder = no
												}
												
												NOT = { de_jure_liege_or_above = PREVPREVPREVPREV }
												ROOT = {
													completely_controls = PREV
												}
											}
										}
									}
									location = {
										duchy = {
											de_jure_liege = PREVPREVPREVPREV
										}
									}
								}
								if = {
									limit = {
										has_alternate_start_parameter = {
											key = dejure_kingdoms
											value = none
										}
									}
									any_title_under = {
										limit = {
											tier = COUNT
											location = {
												duchy = {
													NOT = { de_jure_liege_or_above = PREVPREVPREVPREV }
													ROOT = {
														completely_controls = PREV
													}
												}
											}
										}
										location = {
											duchy = {
												de_jure_liege = PREVPREVPREVPREV
											}
										}
									}
								}
							}
						}
					}
				}

			}
			if = {
				limit = {
					AND = {
						is_alternate_start = yes
						has_alternate_start_parameter = {
							key = dejure_kingdoms
							value = none
						}
					}
				}
				wealth = -50
			}
			if = {
				limit = {
					NOT = {
						is_alternate_start = yes
						has_alternate_start_parameter = {
							key = dejure_kingdoms
							value = none
						}
					}
				}
				wealth = -300
			}
			custom_tooltip = { text = form_new_kingdom_tooltip }
			chronicle = {
				entry = CHRONICLE_FOUNDED_NEW_KINGDOM_OR_EMPIRE
				portrait = [Root.GetID]
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
		}
	}

	form_new_empire = {
		only_independent = yes
		is_high_prio = yes
		ai_check_interval = 24
		
		potential = {
			is_playable = yes
			tier = KING
			
			OR = {
				has_dlc = "Charlemagne"
				AND = {
					is_alternate_start = yes
					OR = {
						has_alternate_start_parameter = {
							key = dejure_kingdoms
							value = none
						}
						has_alternate_start_parameter = {
							key = dejure_empires
							value = none
						}
					}
				}
			}
			
			holy_order = no
			
			NOT = { tier = EMPEROR }
			OR = {
				ai = no
				AND = {
					trait = proud
					prestige = 40000
				}
				AND = {
					trait = ambitious
					prestige = 40000
				}
				prestige = 120000
				AND = {
					is_alternate_start = yes
					OR = {
						has_alternate_start_parameter = {
							key = dejure_kingdoms
							value = none
						}
						has_alternate_start_parameter = {
							key = dejure_empires
							value = none
						}
					}
				}
			}
			
			NOT = {
				has_game_rule = {
					name = dynamic_realms
					value = off
				}
			}
		}
		allow = {
			is_adult = yes
			prisoner = no
			NOT = { trait = incapable }
			independent = yes
			
			conditional_tooltip = {
				trigger = {
					AND = {
						is_alternate_start = yes
						has_alternate_start_parameter = {
							key = dejure_empires
							value = none
						}
					}
				}
				prestige = 2000
				wealth = 200
			}
			
			conditional_tooltip = {
				trigger = {
					NOT = {
						is_alternate_start = yes
						has_alternate_start_parameter = {
							key = dejure_empires
							value = none
						}
					}
				}
				prestige = 8000
				wealth = 1000
			}
			
			OR = {
				realm_size = 180
				custom_tooltip = {
					text = form_new_empire_requirement_tooltip
					hidden_tooltip = {
						any_demesne_title = {
							count = 3
							tier = KING
						}
					}
				}
			}
		}
		effect = {
			primary_title = {
				create_title = {
					tier = EMPEROR
					landless = no
					temporary = no
					custom_created = yes
					culture = ROOT
					holder = ROOT
					base_title = THIS
					copy_title_laws = yes
				}

				new_title = {
					copy_title_history = PREV
				}

				hidden_tooltip = {
					ROOT = {
						primary_title = {
							holder_scope = {
								any_title_under = {
									limit = {
										tier = KING
										NOT = {
											empire = { has_holder = yes }
										}
									}
									de_jure_liege = PREVPREV
								}
								any_title_under = {
									limit = {
										tier = DUKE
										location = {
											kingdom = {
												NOT = {
													empire = { has_holder = yes }
												}
												
												NOT = { de_jure_liege_or_above = PREVPREVPREVPREV }
												ROOT = {
													completely_controls = PREV
												}
											}
										}
									}
									location = {
										kingdom = {
											de_jure_liege = PREVPREVPREVPREV
										}
									}
								}
							}
						}
					}
				}
			}
			
			if = {
				limit = {
					AND = {
						is_alternate_start = yes
						has_alternate_start_parameter = {
							key = dejure_empires
							value = none
						}
					}
				}
				wealth = -200
			}
			if = {
				limit = {
					NOT = {
						is_alternate_start = yes
						has_alternate_start_parameter = {
							key = dejure_empires
							value = none
						}
					}
				}
				wealth = -1000
			}
			
			custom_tooltip = { text = form_new_empire_tooltip }
			chronicle = {
				entry = CHRONICLE_FOUNDED_NEW_KINGDOM_OR_EMPIRE
				portrait = [Root.GetID]
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
		}
	}

	# Hold Wargames - for nomads
	hold_nomad_wargames = {
		only_playable = yes
		ai_check_interval = 4
		
		potential = {
			is_playable = yes
			is_nomadic = yes
			NOT = { has_character_modifier = holding_nomad_wargames }
			NOT = { has_character_modifier = held_nomad_wargames }
		}
		allow = {
			is_adult = yes
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			war = no
			any_demesne_title = {
				NOT = { higher_tier_than = count }
				is_occupied = no
			}
			wealth = 20
			prestige = 100
			custom_tooltip = {
				text = is_not_busy_trigger_tooltip
				hidden_tooltip = { NOT = { has_character_flag = do_not_disturb } }
			}
		}
		effect = {
			wealth = -30
			add_character_modifier = {
				name = holding_nomad_wargames
				duration = -1
			}
			set_character_flag = recent_minor_decision
			set_character_flag = do_not_disturb
			hidden_tooltip = { character_event = { id = HL.7000 } }
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 0.4
			modifier = {
				factor = 0
				NOT = {
					wealth = 200
				}
			}
			modifier = {
				factor = 2
				current_heir = {
					dynasty = ROOT
					combat_rating = 70
				}
			}
			modifier = {
				factor = 0.5
				NOT = { martial = 10 }
			}	
			modifier = {
				factor = 0
				has_character_flag = recent_minor_decision
				NOT = {
					had_character_flag = {
						flag = recent_minor_decision
						days = 730
					}
				}
			}	
		}
	}
	
	convert_to_feudalism_indep  = {
		only_independent = yes
		is_high_prio = yes
		ai_check_interval = 12
		
		potential = {
			is_playable = yes
			is_tribal = yes
			independent = yes
		}
		allow = {
			war = no
			custom_tooltip = {
				text = TT_NOT_UNREFORMED_PAGAN
				hidden_tooltip = {
					OR = {
						NOT = { religion_group = pagan_group }
						is_reformed_religion = yes
					}
				}
			}
			primary_title = { has_law = tribal_organization_4 }
			capital_holding = {
				OR = {
					AND = {
						holding_type = tribal
						has_building = tb_hillfort_4
					}
					holding_type = castle
				}
			}
		}
		
		effect = {
			if = {
				limit = { ai = no }
				set_character_flag = achievement_not_a_tribe
			}
			
			if = {
				limit = {
					NOT = { religion_group = muslim }
				}
				
				if = {
					limit = {
						ai = no
					}
					chronicle = {
						entry = CHRONICLE_ADOPTED_FEUDALISM
						picture = GFX_evt_castle_construction
					}
				}
				set_government_type = feudal_government
			}
			
			if = {
				limit = {
					religion_group = muslim
				}
				
				if = {
					limit = {
						ai = no
					}
					chronicle = {
						entry = CHRONICLE_ADOPTED_IQTA
						picture = GFX_evt_castle_construction
					}
				}
				set_government_type = muslim_government
			}
			
			if = {
				limit = {
					higher_tier_than = king
				}
				primary_title = {
					add_law = feudal_administration
				}
			}
			
			hidden_tooltip = {
				any_demesne_title = {
					limit = {
						tier = baron
						holding_type = tribal
					}
					convert_to = CASTLE
					refill_holding_levy = yes
					location = { #Clear Tribal Great Pillars
						clr_province_flag = flag_great_pillar_norse
						clr_province_flag = flag_great_pillar_tengri
						clr_province_flag = flag_great_pillar_slavic
						clr_province_flag = flag_great_pillar_baltic
						clr_province_flag = flag_great_pillar_finnish
						clr_province_flag = flag_great_pillar_west_african
						clr_province_flag = flag_great_pillar_aztec
						clr_province_flag = flag_great_pillar_bon
						clr_province_flag = flag_great_pillar_zun
						clr_province_flag = flag_great_pillar_hellenic
					}
					
					if = {
						limit = {
							dejure_liege_title = {
								holder = ROOT
								location = {
									num_of_empty_holdings = 2
								}
								NOT = {
									any_direct_de_jure_vassal_title = {
										holding_type = city
									}
								}
							}
						}
						location = {
							build_holding = {
								type = city
							}
						}
					}
					if = {
						limit = {
							dejure_liege_title = {
								holder = ROOT
								location = {
									num_of_empty_holdings = 2
								}
								NOT = {
									any_direct_de_jure_vassal_title = {
										holding_type = temple
									}
								}
							}
						}
						location = {
							build_holding  ={
								type = temple
							}
						}
					}
				}
			}
		}
		
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0
				religion = dryad_religion
			}
		}
	}
	
	convert_to_feudalism_vassal = {
		only_playable = yes
		is_high_prio = yes
		ai_check_interval = 12
		
		potential = {
			is_ruler = yes
			is_tribal = yes
			independent = no
		}
		allow = {
			war = no
			custom_tooltip = {
				text = TT_NOT_UNREFORMED_PAGAN
				hidden_tooltip = {
					OR = {
						NOT = { religion_group = pagan_group }
						is_reformed_religion = yes
					}
				}
			}
			liege = {
				OR = {
					is_feudal = yes
					is_republic = yes
					AND = {
						is_theocracy = yes
						custom_tooltip = {
							text = TT_NOT_UNREFORMED_PAGAN
							hidden_tooltip = {
								OR = {
									NOT = { religion_group = pagan_group }
									is_reformed_religion = yes
								}
							}
						}
					}
				}
			}
			OR = {
				capital_holding = {
					OR = {
						AND = {
							holding_type = tribal
							has_building = tb_hillfort_4
						}
						holding_type = castle
					}
				}
				AND = {
					NOT = { tier = BARON }
					capital_scope = {
						any_province_holding = {
							holding_type = castle
							holder_scope = {
								OR = {
									character = ROOT
									is_liege_or_above = ROOT
								}
							}
						}
					}
				}
			}
		}
		
		effect = {
			set_character_flag = achievement_not_a_tribe
				
			if = {
				limit = {
					ai = no
				}
				chronicle = {
					entry = CHRONICLE_ADOPTED_FEUDALISM
					picture = GFX_evt_castle_construction
				}
			}
			set_government_type = feudal_government
			
			hidden_tooltip = {
				any_demesne_title = {
					limit = {
						tier = baron
						holding_type = tribal
						location = {
							capital_holding = {
								NOT = { holding_type = castle }
							}
						}
					}
					convert_to = CASTLE
					refill_holding_levy = yes
					location = { #Clear Tribal Great Pillars
						clr_province_flag = flag_great_pillar_norse
						clr_province_flag = flag_great_pillar_tengri
						clr_province_flag = flag_great_pillar_slavic
						clr_province_flag = flag_great_pillar_baltic
						clr_province_flag = flag_great_pillar_finnish
						clr_province_flag = flag_great_pillar_west_african
						clr_province_flag = flag_great_pillar_aztec
						clr_province_flag = flag_great_pillar_bon
						clr_province_flag = flag_great_pillar_zun
						clr_province_flag = flag_great_pillar_hellenic
					}
					
					if = {
						limit = {
							dejure_liege_title = {
								holder = ROOT
								location = {
									num_of_empty_holdings = 2
								}
								NOT = {
									any_direct_de_jure_vassal_title = {
										holding_type = city
									}
								}
							}
						}
						location = {
							build_holding = {
								type = city
							}
						}
					}
					if = {
						limit = {
							dejure_liege_title = {
								holder = ROOT
								location = {
									num_of_empty_holdings = 2
								}
								NOT = {
									any_direct_de_jure_vassal_title = {
										holding_type = temple
									}
								}
							}
						}
						location = {
							build_holding = {
								type = temple
							}
						}
					}
				}
				
				liege = {
					character_event = { id = 55100 } # Notify Liege
				}
			}
			
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.01
				liege = {
					OR = {
						NOT = { religion_group = ROOT }
						AND = {
							religion_group = pagan_group
							NOT = { religion = ROOT }
						}
					}
				}
			}
			modifier = {
				factor = 0.1
				liege = {
					NOT = { culture_group = ROOT }
				}
			}
			
			modifier = {
				factor = 0.1
				liege = {
					religion_group = ROOT
					NOT = { religion_group = pagan_group }
					NOT = { religion = ROOT }
				}
			}
			
			modifier = {
				factor = 0
				religion = dryad_religion
			}
		}
	}
	
	convert_to_republic_indep  = {
		only_independent = yes
		is_high_prio = yes
		
		potential = {
			is_playable = yes
			is_tribal = yes
			independent = yes
			has_dlc = "The Republic"
		}
		allow = {
			war = no
			is_female = no
			higher_tier_than = COUNT
			custom_tooltip = {
				text = TT_NOT_UNREFORMED_PAGAN
				hidden_tooltip = {
					OR = {
						NOT = { religion_group = pagan_group }
						is_reformed_religion = yes
					}
				}
			}
			primary_title = { has_law = tribal_organization_4 }
			capital_scope = {
				port = yes
			}
			capital_holding = {
				OR = {
					AND = {
						holding_type = tribal
						has_building = tb_market_town_4
					}
					holding_type = city
				}
			}
		}
		
		effect = {
			hidden_tooltip = {
				create_family_palace = yes
				
				set_government_type = merchant_republic_government
				
				if = {
					limit = {
						NOT = {
							num_of_government_vassals = {
								government = merchant_republic_government
								value = 1
							}
						}
					}
					
					any_unique_dynasty_vassal = { # gives random vassals a family palace
						count = 4
						limit = {
							is_female = no
							OR = {
								is_republic = yes
								is_tribal = yes
							}
							is_patrician = no
							prisoner = no
							NOT = { trait = incapable }
							is_adult = yes
							NOT = { 
								dynasty = none 
							}
						}
						
						if = {
							limit = { is_tribal = yes }
							
							hidden_tooltip = {
								any_demesne_title = {
									limit = {
										tier = baron
										holding_type = tribal
									}
									convert_to = CITY
									refill_holding_levy = yes
									location = { #Clear Tribal Great Pillars
										clr_province_flag = flag_great_pillar_norse
										clr_province_flag = flag_great_pillar_tengri
										clr_province_flag = flag_great_pillar_slavic
										clr_province_flag = flag_great_pillar_baltic
										clr_province_flag = flag_great_pillar_finnish
										clr_province_flag = flag_great_pillar_west_african
										clr_province_flag = flag_great_pillar_aztec
										clr_province_flag = flag_great_pillar_bon
										clr_province_flag = flag_great_pillar_zun
										clr_province_flag = flag_great_pillar_hellenic
									}
									
									if = {
										limit = {
											dejure_liege_title = {
												holder = PREVPREV
												location = {
													num_of_empty_holdings = 2
												}
												NOT = {
													any_direct_de_jure_vassal_title = {
														holding_type = castle
													}
												}
											}
										}
										location = {
											build_holding = {
												type = castle
											}
										}
									}
									if = {
										limit = {
											dejure_liege_title = {
												holder = PREVPREV
												location = {
													num_of_empty_holdings = 2
												}
												NOT = {
													any_direct_de_jure_vassal_title = {
														holding_type = temple
													}
												}
											}
										}
										location = {
											build_holding = {
												type = temple
											}
										}
									}
								}
							}
						}
						
						create_family_palace = yes
					}
				}
				
				any_demesne_title = {
					limit = {
						tier = baron
						holding_type = tribal
					}
					convert_to = CITY
					refill_holding_levy = yes
					location = { #Clear Tribal Great Pillars
						clr_province_flag = flag_great_pillar_norse
						clr_province_flag = flag_great_pillar_tengri
						clr_province_flag = flag_great_pillar_slavic
						clr_province_flag = flag_great_pillar_baltic
						clr_province_flag = flag_great_pillar_finnish
						clr_province_flag = flag_great_pillar_west_african
						clr_province_flag = flag_great_pillar_aztec
						clr_province_flag = flag_great_pillar_bon
						clr_province_flag = flag_great_pillar_zun
						clr_province_flag = flag_great_pillar_hellenic
					}
					
					if = {
						limit = {
							dejure_liege_title = {
								holder = ROOT
								location = {
									num_of_empty_holdings = 2
								}
								NOT = {
									any_direct_de_jure_vassal_title = {
										holding_type = castle
									}
								}
							}
						}
						location = {
							build_holding = {
								type = castle
							}
						}
					}
					if = {
						limit = {
							dejure_liege_title = {
								holder = ROOT
								location = {
									num_of_empty_holdings = 2
								}
								NOT = {
									any_direct_de_jure_vassal_title = {
										holding_type = temple
									}
								}
							}
						}
						location = {
							build_holding  ={
								type = temple
							}
						}
					}
				}
			}
			
			if = {
				limit = { ai = no }
				set_character_flag = achievement_res_publica
			}
			
			if = {
				limit = {
					ai = no
				}
				chronicle = {
					entry = CHRONICLE_FOUNDED_MERCHANT_REPUBLIC
					picture = GFX_evt_busy_trading_dock_republic
				}
			}
			
			set_government_type = merchant_republic_government
		}
		
		ai_will_do = {
			factor = 0
		}
	}
}

targetted_decisions = {
	embrace_mutazila = {
		only_playable = yes
		
		filter = self
		ai_target_filter = self
		ai_check_interval = 60
		
		potential = {
			has_dlc = "Sons of Abraham"
			is_playable = yes
			religion = sunni
			NOT = { 
				OR = {
					trait = mutazilite
					trait = ashari
				}
			}
			is_adult = yes
			prisoner = no
			NOT = {
				has_alternate_start_parameter = { key = religion_names value = random }
			}
		}
		
		allow = {
			piety = 50
		}
		
		effect = {
			add_trait = mutazilite
			character_event = { id = SoA.600 tooltip = EVTTOOLTIP_SoA_600 }
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0
				trait = zealous
			}
			modifier = {
				factor = 1.2
				trait = cynical
			}
			modifier = {
				factor = 1.2
				liege = { trait = mutazilite }
			}
			modifier = {
				factor = 0.5 # Slow it down
			}
		}
	}
	embrace_ashari = {
		only_playable = yes
		ai_check_interval = 60
		
		filter = self
		ai_target_filter = self
		
		potential = {	
			has_dlc = "Sons of Abraham"
			is_playable = yes
			religion = sunni
			NOT = { 
				OR = {
					trait = mutazilite
					trait = ashari
				}
			}
			is_adult = yes
			prisoner = no
			NOT = {
				has_alternate_start_parameter = { key = religion_names value = random }
			}
		}
		
		allow = {
			piety = 50
		}
		
		effect = {
			add_trait = ashari
			character_event = { id = SoA.601 tooltip = EVTTOOLTIP_SoA_601 }
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0
				trait = cynical
			}
			modifier = {
				factor = 1.2
				trait = zealous
			}
			modifier = {
				factor = 1.2
				liege = { trait = ashari }
			}
			modifier = {
				factor = 1.2
				decadence = 40
			}
			modifier = {
				factor = 1.2
				decadence = 60
			}
			modifier = {
				factor = 1.2
				decadence = 80
			}
			modifier = {
				factor = 0.5 # Slow it down
			}
		}
	}
}

