	decisions = {

		restore_luxor = {
			is_high_prio = yes
			ai_check_interval = 12

			only_independent = yes

			potential = {
				independent = yes
				higher_real_tier_than = DUKE

				OR = {
					religion_openly_egyptian_or_reformed_trigger = yes
					religion = aten_pagan
				}

				NOR = {
					has_global_flag = luxor_restored
					has_global_flag = luxor_restoring
				}
			}

			allow = {
				has_landed_title = c_esna
				wealth >= 1000
				war = no
				has_regent = no
			}

			effect = {
				set_global_flag = luxor_restoring
				wealth = -1000
				c_esna = {
					location = {
						province_event = { id = ancrel.4000 }
					}
				}
			}

			ai_will_do = {
				factor = 1

				trigger = {
					wealth >= 1500
					learning >= 8
				}
			}
		}

		build_pyramid = {
			is_high_prio = yes
			ai_check_interval = 12

			only_playable = yes

			potential = {
				higher_real_tier_than = DUKE

				OR = {
					religion_openly_egyptian_or_reformed_trigger = yes
					religion = aten_pagan
				}

				NOR = {
					has_character_flag = pyramid_built
					has_character_flag = pyramid_building_char
					capital_scope = { has_province_flag = pyramid_building_prov }
				}
			}

			allow = {
				wealth >= 600
				war = no
				has_regent = no
			}

			effect = {
				set_character_flag = pyramid_building_char
				character_event = { id = ancrel.4004 }
			}

			ai_will_do = {
				factor = 1

				trigger = {
					wealth >= 1000
					learning >= 8
				}
			}
		}

	#	restore_priesthood_egyptian_pagan = {
	#		is_high_prio = yes
	#		ai_check_interval = 12
	#		icon_religion = egyptian_pagan
	#
	#		only_playable = yes
	#
	#		potential = {
	#			higher_real_tier_than = DUKE
	#
	#			OR = {
	#				religion = egyptian_pagan
	#				religion = aten_pagan
	#			}
	#
	#			NOT = { has_global_flag = egyptian_priesthood_founded }
	#		}
	#
	#		allow = {
	#			real_tier = EMPEROR
	#			completely_controls = b_luxor
	#			realm_learning >= 25
	#			piety >= 500
	#			wealth >= 500
	#			religion_authority >= 0.6
	#			war = no
	#			is_not_in_regency_trigger = yes
	#		}
	#
	#		effect = {
	#			set_global_flag = egyptian_priesthood_founded
	#			wealth = -500
	#			piety = -250
	#			prestige = 250
	#
	#			activate_title = {
	#				title = d_egyptian_pagan_reformed
	#				status = yes
	#			}
	#
	#			gain_title = d_egyptian_pagan_reformed
	#			narrative_event = { id = ancrel.4006 }
	#
	#			if = {
	#				limit = { ai = no }
	#
	#				chronicle = {
	#					entry = CHRONICLE_EGYPTIAN_PRIESTHOOD
	#					portrait = [Root.GetID]
	#				}
	#			}
	#		}
	#
	#		ai_will_do = {
	#			factor = 1
	#		}
	#	}

	organize_anubis = {
		is_high_prio = yes
		ai_check_interval = 12

		only_playable = yes

		potential = {
			higher_real_tier_than = DUKE

			OR = {
				religion_openly_egyptian_or_reformed_trigger = yes
				religion = aten_pagan
			}

			NOR = {
				has_global_flag = anubis_founded
				has_global_flag = horus_founded
			}
		}

		allow = {
			prestige >= 300
			wealth >= 300
			is_not_in_regency_trigger = yes
		}

		effect = {
			set_global_flag = anubis_founded
			prestige = -300
			wealth = -300

			activate_title = {
				title = d_anubis
				status = yes
			}

			hidden_effect = {
				d_horus = {
					religion = ROOT

					ROOT = {
						religion_scope = { save_event_target_as = anubis_religion }
					}

					save_persistent_event_target = {
						name = holy_order_religion
						scope = event_target:anubis_religion
					}
				}

				create_character = {
					random_traits = yes
					religion = ROOT
					culture = egyptian_arabic
					dynasty = none
					age = 34

					attributes = {
						martial = 7
						diplomacy = 5
						intrigue = 2
						learning = 2
						stewardship = 2
					}
				}

				new_character = {
					grant_title = d_anubis
					set_defacto_liege = ROOT
					save_event_target_as = anubis_leader
				}

				set_character_flag = event_ancrel.4007
				narrative_event = { id = ancrel.4007 }
			}

			if = {
				limit = { ai = no }

				chronicle = {
					entry = CHRONICLE_ANUBIS_GUARD
					portrait = [anubis_leader.GetID]
				}
			}
		}

		ai_will_do = {
			factor = 1
		}
	}

	organize_horus = {
		is_high_prio = yes
		ai_check_interval = 12

		only_playable = yes

		potential = {
			higher_real_tier_than = DUKE

			OR = {
				religion_openly_egyptian_or_reformed_trigger = yes
				religion = aten_pagan
			}

			has_global_flag = anubis_founded
			NOT = { has_global_flag = horus_founded }
		}

		allow = {
			real_tier = EMPEROR
			prestige = 300
			wealth = 300
			is_not_in_regency_trigger = yes
		}

		effect = {
			set_global_flag = horus_founded
			prestige = -300
			wealth = -300

			activate_title = {
				title = d_horus
				status = yes
			}

			hidden_effect = {
				d_horus = {
					religion = ROOT

					ROOT = {
						religion_scope = { save_event_target_as = horus_religion }
					}

					save_persistent_event_target = {
						name = holy_order_religion
						scope = event_target:horus_religion
					}
				}

				create_character = {
					random_traits = yes
					religion = ROOT
					culture = egyptian_arabic
					dynasty = none
					age = 34

					attributes = {
						martial = 7
						diplomacy = 5
						intrigue = 2
						learning = 2
						stewardship = 2
					}
				}

				new_character = {
					grant_title = d_horus
					set_defacto_liege = ROOT
					save_event_target_as = horus_leader
				}

				set_character_flag = event_ancrel.4008
				narrative_event = { id = ancrel.4008 }
			}

			if = {
				limit = { ai = no }

				chronicle = {
					entry = CHRONICLE_HORUS_GUARD
					portrait = [horus_leader.GetID]
				}
			}
		}

		ai_will_do = {
			factor = 1
		}
	}

	# Create Egyptian Warrior Lodge - Dead at start.
	create_warrior_lodge_egyptian = {
		is_high_prio = yes
		ai_check_interval = 120

		only_playable = yes

		potential = {
			religion_openly_egyptian_or_reformed_trigger = yes
			has_dlc = "Holy Fury"
			warrior_lodge_egyptian = { society_has_members = no }

			NOR = {
				has_global_flag = flag_restored_warrior_lodge_egyptian
				has_religion_feature = religion_peaceful

				has_alternate_start_parameter = {
					key = religion_names
					value = random
				}
			}
		}

		allow = {
			is_in_society = no
			has_education_martial_trigger = yes
			higher_real_tier_than = DUKE
			martial >= 15
			scaled_wealth = 0.75
			prestige >= 1500
			is_adult = yes
			is_inaccessible_trigger = no
			is_incapable = no
		}

		effect = {
			scaled_wealth = -0.75
			prestige = -1500

			custom_tooltip = {
				text = create_warrior_lodge_egyptian_tooltip

				set_global_flag = flag_restored_warrior_lodge_egyptian
				join_society = warrior_lodge_egyptian
				set_society_grandmaster = yes

				add_society_currency_massive_effect = yes

				while = {
					count = 6

					spawn_good_commander_effect = yes
					new_character = { join_society = warrior_lodge_egyptian }
				}

				any_vassal = {
					limit = {
						ai = yes
						can_join_society = warrior_lodge_egyptian
					}

					random = {
						chance = 75
						join_society = warrior_lodge_egyptian
					}
				}

				any_neighbor_independent_ruler = {
					limit = {
						ai = yes
						can_join_society = warrior_lodge_egyptian
					}

					random = {
						chance = 35
						join_society = warrior_lodge_egyptian
					}
				}

				any_player = {
					limit = {
						OR = {
							religion_openly_egyptian_or_reformed_trigger = yes
							is_within_diplo_range = ROOT
						}
					}

					narrative_event = { id = egyptian.400 }
				}
			}
		}

		ai_will_do = {
			factor = 1
		}
	}
}