decisions = {

	make_sacrifice = {
		only_rulers = yes
		ai_check_interval = 3
		potential = {
			is_ruler = yes
			has_regent = no
			OR = {
				religion = zoroastrian
				religion = mazdaki
				religion = zurvanist
			}
			OR = {
				NOT = { has_character_flag = made_sacrifice_1 }
				had_character_flag = { flag = made_sacrifice_1 days = 3650 }
			}
		}
		allow = {
			war = no
			piety = 100
			scaled_wealth = 0.3
		}
		effect = {
			set_character_flag = made_sacrifice_1
			character_event = { id = GoPagan.220 }
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 2.5 }
			}
			modifier = {
				factor = 0
				trait = cynical
			}
			modifier = {
				factor = 0
				NOT = {
					piety = 120
					learning = 8
				}
			}
		}
	}

	rebuild_persepolis = {
		is_high_prio = yes
		only_rulers = yes
		ai_check_interval = 12
		potential = {
			is_ruler = yes
			OR = {
				religion = zoroastrian
				religion = mazdaki
				religion = zurvanist
			}
			NOT = { has_global_flag = persepolis_rebuilt }
			NOT = { has_global_flag = rebuilding_persepolis }
			OR = {
				has_landed_title = k_persia
				has_landed_title = e_persia
			}
		}
		allow = {
			war = no
			has_regent = no
			wealth = 1000
			has_landed_title = b_esfahan
			capital_scope = { province_id = 646 }
			646 = { num_of_empty_holdings = 1 }
		}
		effect = {
			set_global_flag = rebuilding_persepolis
			wealth = -1000
			hidden_tooltip = {
				character_event = { id = GoPagan.205 }
				646 = { set_province_flag = reb_pers_1 }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { wealth = 1500 }
			}
			modifier = {
				factor = 0
				NOT = { learning = 8 }
			}
		}
	}

	undergo_cleansing_ritual = {
		only_rulers = yes
		ai_check_interval = 3
		potential = {
			is_ruler = yes
			has_regent = no
			OR = {
				religion = zoroastrian
				religion = mazdaki
				religion = zurvanist
				religion = mandaean
			}
			OR = {
				NOT = { has_character_flag = undergoing_cleansing_ritual }
				had_character_flag = { flag = undergoing_cleansing_ritual days = 3650 }
			}
			NOT = {
				any_demesne_title = { NOT = { higher_tier_than = count } is_occupied = yes }
			}
		}
		allow = {
			war = no
			scaled_wealth = 0.3
		}
		effect = {
			set_character_flag = undergoing_cleansing_ritual
			scaled_wealth = -0.3
			character_event = { id = GoPagan.225 }
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 2.5 }
			}
			modifier = {
				factor = 0
				trait = cynical
			}
		}
	}

	organize_zhayedan_1 = {
		is_high_prio = yes
		ai_check_interval = 3
		potential = {
			OR = {
				has_landed_title = k_persia
				has_landed_title = e_persia
			}
			OR = {
				religion = zoroastrian
				religion = mazdaki
				religion = zurvanist
			}
			NOT = { has_global_flag = zhayedan_founded }
			NOT = { has_global_flag = zhayedan_expanded }
		}
		allow = {
			prestige = 300
			wealth = 300
			has_regent = no
			is_heretic = no
		}
		effect = {
			set_global_flag = zhayedan_founded
			prestige = -300
			wealth = -300
			activate_title = { title = d_immortals status = yes }
			hidden_tooltip = {
				set_character_flag = event_1000182157
				narrative_event = { id = SoA.1809 }
				create_character = {
					random_traits = no
					religion = ROOT
					culture = ROOT
					dynasty = culture
					age = 34
					trait = brilliant_strategist
					trait = strong
					trait = lustful
					trait = cruel
					trait = cavalry_leader
					attributes = {
						martial = 7
						diplomacy = 5
						intrigue = 2
						learning = 2
						stewardship = 2
					}
				}
				new_character = {
					d_immortals = {
						grant_title = PREV
					}
					create_character = {
						random_traits = yes
						dynasty = random
						religion = ROOT
						culture = persian
						female = no
						age = 16
					}
					create_character = {
						random_traits = yes
						dynasty = random
						religion = ROOT
						culture = persian
						female = no
						age = 18
					}
					create_character = {
						random_traits = yes
						dynasty = random
						religion = ROOT
						culture = persian
						female = no
						age = 18
					}
					create_character = {
						random_traits = yes
						dynasty = random
						religion = ROOT
						culture = persian
						female = no
						age = 20
					}
					create_character = {
						random_traits = yes
						dynasty = random
						religion = ROOT
						culture = persian
						female = no
						age = 25
					}
					create_character = {
						random_traits = yes
						dynasty = random
						religion = ROOT
						culture = persian
						female = no
						age = 26
					}
					create_character = {
						random_traits = yes
						dynasty = random
						religion = ROOT
						culture = persian
						female = no
						age = 28
					}
					create_character = {
						random_traits = yes
						dynasty = random
						religion = ROOT
						culture = persian
						female = yes
						age = 16
					}
					create_character = {
						random_traits = yes
						dynasty = random
						religion = ROOT
						culture = persian
						female = yes
						age = 17
					}
					set_defacto_liege = ROOT
				}
			}
		}
		ai_will_do = {
			factor = 1
		}
	}

	organize_zhayedan_2 = {
		is_high_prio = yes
		ai_check_interval = 3
		potential = {
			always = no # removed this until change_title_army_size is fixed
			has_landed_title = e_persia
			OR = {
				religion = zoroastrian
				religion = mazdaki
				religion = zurvanist
			}
			has_global_flag = zoroastrian_priesthood_founded
			has_global_flag = zhayedan_founded
			NOT = { has_global_flag = zhayedan_expanded }
		}
		allow = {
			prestige = 300
			wealth = 300
			has_regent = no
			is_heretic = no
		}
		effect = {
			set_global_flag = zhayedan_expanded
			prestige = -300
			wealth = -300
			hidden_tooltip = {
				set_character_flag = expanded_zhayedan
				narrative_event = { id = GoPagan.216 }
				d_immortals = {
					change_title_army_size = 1.00 # Increase of percentage
				}
			}
		}
		ai_will_do = {
			factor = 1
		}
	}

	observe_bema_feast = {
		only_rulers = yes
		ai_check_interval = 3
		potential = {
			is_ruler = yes
			religion = manichean
			NOT = {
				is_inaccessible_trigger = yes
				any_demesne_title = { NOT = { higher_tier_than = count } is_occupied = yes }
				has_character_modifier = held_bema_feast_timer
				liege = { has_character_flag = holding_bema_feast }
				has_character_flag = holding_bema_feast
				has_character_flag = planning_bema_feast
			}
		}
		allow = {
			war = no
			wealth = 50
			prestige = 100
			has_regent = no
			custom_tooltip = {
				text = HAS_THREE_MANICHEAN_VASSALS_AVAILABLE
				hidden_tooltip = {
					any_vassal = {
						religion = manichean
						has_regent = no
						war = no
						count = 3
					}
				}
			}
		}
		effect = {
			wealth = -50
			set_character_flag = planning_bema_feast
			custom_tooltip = {
				text = prepare_bema_feast
				hidden_tooltip = {
					character_event = { id = GoPagan.238 }
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { month = 3 }
				month = 6
			}
			modifier = {
				factor = 0
				NOT = {
					wealth = 300
				}
			}
			modifier = {
				factor = 0
				trait = shy
			}
			modifier = {
				factor = 0
				NOT = { diplomacy = 10 }
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}

	manichean_choose_patron_deity = {

		icon_religion = manichean
		only_playable = yes
		ai_check_interval = 12

		potential = {
			religion = manichean
			OR = {
				is_playable = yes
				capital_holding = { holding_type = temple }
				trait = detached_priest
				trait = martial_cleric
				trait = scholarly_theologian
				trait = mastermind_theologian
			}
			NOR = {
				has_character_modifier = patron_reason
				has_character_modifier = patron_mind
				has_character_modifier = patron_thought
				has_character_modifier = patron_intelligence
				has_character_modifier = patron_mani_understanding
			}
		}
		allow = {
			war = no
			is_adult = yes
			prisoner = no
			NOT = { trait = incapable }
		}
		effect = {
			character_event = { id = GoPagan.226 tooltip = choose_mani_patron }
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 5
				trait = zealous
			}
			modifier = {
				factor = 0.5
				trait = cynical
			}
		}
	}

	manichean_create_leader = {
		is_high_prio = yes
		icon_religion = manichean
		ai_check_interval = 3
		potential = {
			religion = manichean
			NOT = {
				any_demesne_title = { temporary = yes }
				is_title_active = d_manichean
			}
		}
		allow = {
			war = no
			has_regent = no
			independent = yes
			num_of_holy_sites = 3
			piety = 1000
		}
		effect = {
			prestige = 1000
			activate_title = { title = d_manichean status = yes }
			narrative_event = { id = GoPagan.228 tooltip = CREATE_MANICHEAN_LEADER }
		}
		ai_will_do = {
			factor = 1
		}
	}

	manichean_patronize_art = {
		only_rulers = yes
		ai_check_interval = 12
		potential = {
			is_ruler = yes
			is_tribal = no
			OR = {
				religion = manichean
				religion = mandaean
			}
			OR = {
				trait = poet
				trait = charitable
				trait = zealous
			}
			NOT = { has_character_modifier = mani_art_patron }
		}
		allow = {
			scaled_wealth = 2.0
		}
		effect = {
			scaled_wealth = -2.0
			add_character_modifier = {
				name = mani_art_patron
				duration = -1
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					trait = greedy
					trait = cynical
					has_character_modifier = ai_austerity
					NOT = { scaled_wealth = 4.0 }
				}
			}
		}
	}

	organise_army_of_light = {
		is_high_prio = yes
		only_rulers = yes
		ai_check_interval = 12
		potential = {
			is_ruler = yes
			higher_tier_than = count
			religion = manichean
			NOT = { is_title_active = d_army_light }
		}
		allow = {
			has_regent = no
			higher_tier_than = duke
			prestige = 300
			wealth = 300
		}
		effect = {
			prestige = -300
			wealth = -300
			activate_title = { title = d_army_light status = yes }
			hidden_tooltip = {
				narrative_event = { id = GoPagan.229 }
				create_character = {
					random_traits = yes
					religion = ROOT
					culture = ROOT
					dynasty = NONE
					female = no
					age = 34
					trait = skilled_tactician
					trait = zealous
				}
				new_character = {
					d_army_light = {
						grant_title = PREV
					}
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					NOT = { prestige = 500 }
					NOT = { wealth = 500 }
				}
			}
		}
	}

	expel_army_of_light = {
		only_independent = yes
		potential = {
			ai = no
			has_dlc = "Sons of Abraham"
			OR = {
				religion = manichean
				religion = mandaean
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_army_light
			NOT = { has_character_modifier = expelled_d_army_light }
			any_realm_province = {
				any_province_lord = {
					d_army_light = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
		}
		allow = {
			piety = 1000
		}
		effect = {
			set_character_flag = expel_army_of_light_check
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip_b
				hidden_tooltip = {
					character_event = { id = SoA.2990 }
				}
			}
		}
		ai_will_do = {
			factor = 0
		}
	}

	donate_money_to_army_of_light = {
		ai_check_interval = 60
		potential = {
			has_dlc = "Sons of Abraham"
			OR = {
				religion = manichean
				religion = mandaean
			}
			is_heretic = no
			is_title_active = d_army_light
			NOR = {
				has_character_modifier = expelled_d_army_light
				has_character_modifier = donated_to_holy_order
				has_landed_title = d_army_light
			}
			d_army_light = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		allow = {
			wealth = 300
		}
		effect = {
			wealth = -300
			piety = 300
			if = {
				limit = {
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			hidden_tooltip = {
				d_army_light = {
					holder_scope = {
						character_event = {
							id = GoPagan.230
						}
					}
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					trait = cynical
					trait = greedy
					piety = 1000
					NOT = { wealth = 1000 }
				}
			}
			modifier = {
				factor = 10
				trait = zealous
			}
			modifier = {
				factor = 10
				NOT = { piety = 100 }
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}

	vassalize_manichean_leader = {
		is_high_prio = yes
		icon_religion = manichean
		only_playable = yes

		potential = {
			is_playable = yes
			religion = manichean
			controls_religion = no
			d_manichean = {
				has_holder = yes
				holder_scope = {
					independent = yes
					lower_tier_than = KING
					any_demesne_title = { controls_religion = no }
				}
			}
		}
		allow = {
			war = no
			piety = 500
			higher_tier_than = DUKE
			any_realm_title = { is_holy_site = ROOT }
			religion_head = {
				war = no
				opinion = { who = ROOT value = 0 }
			}
		}
		effect = {
			piety = 500
			religion_head = {
				add_friend = ROOT
				ROOT = {
					random_realm_title = {
						limit = { is_holy_site = PREV }
						grant_title = PREVPREV
					}
				}
				set_defacto_liege = ROOT
				pf_liege_change_effect = yes
			}
		}
		ai_will_do = {
			factor = 1
		}
	}

	mazdaki_restore_priesthood = {
		is_high_prio = yes
		icon_religion = mazdaki
		ai_check_interval = 12
		potential = {
			has_dlc = "The Old Gods"
			religion = mazdaki
			NOT = {
				any_demesne_title = { temporary = yes }
				is_title_active = d_mazdaki
			}
		}
		allow = {
			war = no
			has_regent = no
			independent = yes
			has_landed_title = k_persia
			num_of_holy_sites = 1
			piety = 1000
		}
		effect = {
			piety = 500
			activate_title = { title = d_mazdaki status = yes }
			narrative_event = { id = GoPagan.258 tooltip = RESTORE_MAZDAKI_PRIESTHOOD }
		}
		ai_will_do = {
			factor = 1
		}
	}

	mazdaki_choose_patron_deity = {

		icon_religion = mazdaki
		only_playable = yes
		ai_check_interval = 12

		potential = {
			religion = mazdaki
			OR = {
				is_playable = yes
				capital_holding = { holding_type = temple }
				trait = detached_priest
				trait = martial_cleric
				trait = scholarly_theologian
				trait = mastermind_theologian
			}
			NOR = {
				has_character_modifier = patron_discernment
				has_character_modifier = patron_understanding
				has_character_modifier = patron_preservation
				has_character_modifier = patron_joy
			}
		}
		allow = {
			war = no
			is_adult = yes
			prisoner = no
			NOT = { trait = incapable }
		}
		effect = {
			character_event = { id = GoPagan.259 tooltip = choose_mazdaki_patron }
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 5
				trait = zealous
			}
			modifier = {
				factor = 0.5
				trait = cynical
			}
		}
	}

	yazidi_peacock_feast = {
		only_rulers = yes
		ai_check_interval = 12
		potential = {
			is_ruler = yes
			religion = yazidi
			num_of_vassals = 1
			OR = {
				is_feudal = yes
				is_tribal = yes
				is_nomadic = yes
				is_patrician = yes
			}
			NOR = {
				is_inaccessible_trigger = yes
				any_demesne_title = { NOT = { higher_tier_than = count } is_occupied = yes }
				has_character_flag = planning_peacock_feast
				has_character_flag = holding_peacock_feast
				liege = { has_character_flag = holding_peacock_feast }
			}
			OR = {
				NOT = { has_character_flag = held_recent_feast }
				had_character_flag = { flag = held_recent_feast days = 365 }
			}
		}
		allow = {
			war = no
			has_regent = no
			scaled_wealth = 0.5
			prestige = 100
			is_not_busy_trigger = yes
			custom_tooltip = {
				text = HAS_THREE_YAZIDI_VASSALS_AVAILABLE
				hidden_tooltip = {
					any_vassal = {
						religion = yazidi
						prisoner = no
						NOT = { trait = incapable }
						is_not_busy_trigger = yes
						war = no
						is_adult = yes
						count = 3
					}
				}
			}
		}
		effect = {
			log = "[Root.GetTitledName] is holding a peacock feast"
			scaled_wealth = -0.5
			set_character_flag = planning_peacock_feast
			hidden_tooltip = {
				character_event = { id = GoPagan.260 }
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					NOT = { month = 5 }
					month = 10
				}
			}
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 5.0 }
				NOR = {
					trait = charitable
					trait = gregarious
					trait = gluttonous
					trait = zealous
				}
			}
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 2.5 }
			}
			modifier = {
				factor = 0
				OR = {
					trait = shy
					trait = greedy
					trait = paranoid
				}
			}
			modifier = {
				factor = 0
				has_character_flag = held_recent_feast
				NOT = { had_character_flag = { flag = held_recent_feast days = 1825 } }
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}

	yazidi_pilgrimage = {
		only_rulers = yes
		ai_check_interval = 12
		potential = {
			is_female = no
			is_ruler = yes
			religion = yazidi
			NOR = {
				is_inaccessible_trigger = yes
				trait = yazidi_pilgrim
				trait = on_pilgrimage
				any_demesne_title = { NOT = { higher_tier_than = count } is_occupied = yes }
				has_character_flag = preparing_yazidi_pilgrimage
				has_character_flag = planning_peacock_feast
			}
		}
		allow = {
			war = no
			in_command_trigger = no
			is_abroad_trigger = no
			has_regent = no
			scaled_wealth = 1.0
			custom_tooltip = {
				text = health_travel_condition
				hidden_tooltip = {
					is_pregnant = no
					NOT = {	trait = incapable }
					NOT = { trait = infirm }
					NOT = {	trait = blinded }
					is_ill = no
				}
			}
			is_not_busy_trigger = yes
		}
		effect = {
			log = "[Root.GetTitledName] is going on yazidi pilgrimage"
			set_character_flag = preparing_yazidi_pilgrimage
			scaled_wealth = -1.0
			custom_tooltip = {
				text = PREPARE_FOR_PILGRIMAGE
				hidden_tooltip = {
					character_event = { id = GoPagan.279 }
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					NOT = { month = 7 }
					month = 9
				}
			}
			modifier = {
				factor = 0
				trait = cynical
			}
			modifier = {
				factor = 0
				OR = {
					trait = slothful
					trait = proud
					trait = deceitful
				}
				NOT = { trait = decadent }
			}
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 5.0 }
			}
			modifier = {
				factor = 0.5
			}
			modifier = {
				factor = 0
				NOT = { age = 30 }
			}
		}
	}

	yazidi_renounce_heresy = {
		is_high_prio = yes
		only_rulers = yes
		ai_check_interval = 3
		potential = {
			religion = yazidi
			is_ruler = yes
			is_heretic = yes
			NOT = { has_global_flag = yazidi_faith_no_heresy }
		}
		allow = {
			war = no
			has_regent = no
			independent = yes
			piety = 1000
			prestige = 1000
			higher_tier_than = DUKE
			num_of_holy_sites = 1
			capital_scope = { religion = yazidi }
			OR = {
				controls_religion = yes
				any_realm_lord = { controls_religion = yes }
			}
		}
		effect = {
			set_global_flag = yazidi_faith_no_heresy
			if = {
				limit = {
					NOT = { trait = paragon }
				}
				add_trait = paragon
			}
			give_nickname = nick_the_great
			set_parent_religion = { religion = yazidi parent = 0 }
			hidden_tooltip = {
				narrative_event = { id = GoPagan.285 }
			}
		}
		ai_will_do = {
			factor = 1
		}
	}

	celebrate_nowruz = {

		only_playable = yes
		ai_check_interval = 12
		potential = {
			OR = {
				religion_group = zoroastrian_group
				culture_group = iranian
			}
			has_regent = no
			NOT = { is_inaccessible_trigger = yes }
			NOR = {
				has_character_flag = planning_nowruz
				has_character_flag = celebrating_nowruz
				trait = incapable
				has_character_modifier = celebration_nowruz_large
				has_character_modifier = celebration_nowruz_small
				has_character_modifier = feast_event_timer
				has_character_modifier = holding_large_feast
				has_character_flag = planning_feast
			}
		}
		allow = {
			war = no
			prisoner = no
			prestige = 100

			is_not_busy_trigger = yes
		}

		effect = {
			if = {
				limit = {
					NAND = {
						month = 2
						NOT = { month = 3 }
					}
				}
				set_character_flag = planning_nowruz
				custom_tooltip = { text = PLANNING_NOWRUZ }
			}
			if = {
				limit = {
					month = 2
					NOT = { month = 3 }
				}
				set_character_flag = do_not_disturb
				custom_tooltip = { text = CELEBRATING_NOWRUZ }
				hidden_tooltip = {
					character_event = { id = GoPagan.288 days = 2 }
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1
				always = yes
			}
			modifier = {
				factor = 5
				trait = zealous
			}
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 0
				NOT = {
					wealth = 300
				}
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
}
