decisions = {

#### Mandean decisions
invite_mandeans = { 
  ai_check_interval = 150 # Determines how seldom the AI checks whether they can and should do the decision, in months. By default 1 (every month).
  is_high_prio = yes
  potential = {
    religion = mandean
	is_playable = yes
	is_adult = yes
	independent = yes
	NOT = {
		any_realm_province = {
			religion = mandean
		}
	}
  }
  
  allow = {
	primary_title = { higher_tier_than = COUNT }
	prisoner = no
	wealth = 125
	OR = {
		any_realm_province = {
			culture_group = byzantine
		}
		any_realm_province = {
			culture_group = arabic
		}
		any_realm_province = {
			culture_group = iranian
		}
		any_realm_province = {
			culture_group = east_african
		}
	}

  }
  effect = {
    character_event = { id = CIML.349 }
	capital_scope = { religion = mandean }
	wealth = -125
  }
  ai_will_do = {
    #Factors for an AI character to take the decision (1 = 100% chance)
  }
}

mandean_zodiac = {
		is_high_prio = yes
		#ai_check_interval = 12 #check only once every 12 months.
		potential = {
			NOR = { 
				trait = zodiac_aquarius
				trait = zodiac_aries
				trait = zodiac_cancer
				trait = zodiac_capricorn
				trait = zodiac_gemini
				trait = zodiac_leo
				trait = zodiac_libra
				trait = zodiac_pisces
				trait = zodiac_sagittarius
				trait = zodiac_scorpio
				trait = zodiac_taurus
				trait = zodiac_virgo
			}
			has_dlc = "Holy Fury"
			religion = mandean
		}
		
		allow = {
			prisoner = no
			NOT = { trait = incapable }
			learning = 6
		}
		
		effect = {
			custom_tooltip = {
				text = gain_zodiac_trait_effect_tt
			}
			hidden_tooltip = {
				add_western_zodiac_trait_effect = yes
				character_event = { id = HFP.23925 }
			}
		}
		revoke_allowed = {
			always = no
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 1.5
				trait = zealous
			}
			modifier = {
				factor = 0.1
				trait = cynical
			}
		}
}

reject_ascetism = {
		is_high_prio = yes
		#ai_check_interval = 150 #check only once every 6 months.
		potential = {
			AND = {
				OR = {
					religion = mandean
					religion = messalian
				}
				trait = celibate
			}
		}
		
		allow = {
			NOT = { trait = incapable }
		}
		
		effect = {
			remove_trait = celibate
		}
}

# Create Mandean religious head
form_mandean_papacy = { 
  is_high_prio = yes
  ai_check_interval = 30 # Determines how seldom the AI checks whether they can and should do the decision, in months. By default 1 (every month).
  potential = {
    religion = mandean
	is_theocracy = yes 
	is_adult = yes
	d_mandean = {
		has_holder = no
	}
  }
  
  allow = {
	prisoner = no
	prestige = 20
	piety = 20
	wealth = 20
	NOR = {
		trait = naive_appeaser
		trait = tough_soldier
		trait = indulgent_wastrel
		trait = amateurish_plotter
		trait = detached_priest
		trait = incapable
		trait = lunatic
		trait = possessed
		trait = bastard
		trait = legit_bastard
		trait = imbecile
		trait = slothful
		trait = cynical
		trait = bad_priest_christian
		trait = eunuch
		trait = celibate
	}
	OR = {
		completely_controls = c_jerusalem
		completely_controls = c_gizeh
		completely_controls = c_tiberias
		completely_controls = c_baghdad
		completely_controls = c_khozistan
		any_liege = {
			AND = {
				religion = mandean
				OR = {
					completely_controls = c_jerusalem
					completely_controls = c_gizeh
					completely_controls = c_tiberias
					completely_controls = c_baghdad
					completely_controls = c_khozistan
				}
			}
		}
	}
  }
  effect = {
	any_player = {
		narrative_event = { id = CIML.808 }
	}
	religion_authority = {
		modifier = patriarchy_instituted
		years = 15
	}
	d_mandean = {
		grant_title = ROOT
	}
  }
  ai_will_do = {
    #Factors for an AI character to take the decision (1 = 100% chance)
  }
}

# Ascent of the dead
order_masiqta = { 
  ai_check_interval = 350 # Determines how seldom the AI checks whether they can and should do the decision, in months. By default 1 (every month).
  potential = {
	religion = mandean
	is_adult = yes
  }
  
  allow = {	
	wealth = 125
	prisoner = no
	in_seclusion = no
	NOT = { trait = incapable }
	NOT = { trait = cynical }
	NOT = { trait = greedy }
	NOT = { has_character_modifier = mandean_requiem_dynasty }
	NOT = { has_character_modifier = mandean_requiem_army }
	NOT = { has_character_modifier = mandean_requiem_poor }
	NOT = { has_character_modifier = mandean_requiem_church }
	OR = {
		trait = charitable
		AND {
			trait = zealous
			trait = kind
		}
		ai = no
	}
  }

  effect = {
	character_event = { id = CIML.809 }
	scaled_wealth = -0.20
  }
}

# Mandean incantation bowl for lunatics and possessed
mandean_incantation_bowl = { 
  is_high_prio = yes
  ai_check_interval = 200 # Determines how seldom the AI checks whether they can and should do the decision, in months. By default 1 (every month).
  potential = {
	OR = {
		trait = possessed
		trait = lunatic
	}
	religion = mandean
	NOT = { has_character_flag = mandean_bowl }
  }
  
  allow = {	
  wealth = 10
  prisoner = no
  NOT = { trait = incapable }
  NOT = {
	OR = {
		AND = { 
			trait = cynical
			trait = proud
		}
		AND = { 
			trait = cynical
			trait = stubborn
		}
	society_is_devil_worshiper = yes
	has_secret_religion = yes
	}
  }
 }

  effect = {
	character_event = { id = CIML.810 }
	wealth = -10
	set_character_flag = mandean_bowl
  }
}

#### Yarsan decisions
yarsan_fast = { 
  ai_check_interval = 50 # Determines how seldom the AI checks whether they can and should do the decision, in months. By default 1 (every month).
  is_high_prio = no
  potential = {
    religion = yarsan
	is_playable = yes
  }
  
  allow = {
	prisoner = no
	is_adult = yes
	is_female = no
	NOT = { trait = incapable }
	NOT = { has_disease = yes }
	NOT = { has_character_modifier = fast_of_sultan_sahak }
	prisoner = no
	in_seclusion = no
	month = 9
	NOT = {
		month = 11
	}
  }
  effect = {
    character_event = { id = CIML.350 }
	add_character_modifier = { 
	name = fast_of_sultan_sahak
	months = 4 
	}
  }
  ai_will_do = {
    #Factors for an AI character to take the decision (1 = 100% chance)
  }
}

invite_yarsan_sayyid = {
		ai_check_interval = 12 # Determines how seldom the AI checks whether they can and should do the decision, in months. By default 1 (every month).
		is_high_prio = yes

		potential = {
			religion = yarsan
			OR = {
				independent = yes
				primary_title = { higher_tier_than = COUNT }
			}
		}
		allow = {
			NOT = {
				any_courtier = {
				trait = yarsan_sayyid
				}
			}
		}
		effect = {
			create_random_priest = {
				random_traits = yes
				dynasty = random
				female = no
				attributes = {
					diplomacy = 2
					learning = 8
					stewardship = 2
					intrigue = 2
					martial = 2
				}
			}
			if = {
				limit = {
					ai = no
					}
				wealth = -50
			}
			new_character = {
				remove_trait = slow
				remove_trait = imbecile
				remove_trait = dull
				
				remove_trait = mystic
				remove_trait = socializer
				remove_trait = gamer
				remove_trait = hedonist
				remove_trait = duelist
				remove_trait = hunter
				remove_trait = strategist
				remove_trait = administrator
				remove_trait = architect
				remove_trait = gardener
				remove_trait = schemer
				remove_trait = impaler
				remove_trait = seducer
				remove_trait = seductress
				remove_trait = theologian
				remove_trait = scholar
				
				random_list = { # Flavor Randomization
					35 = {  } # Nothing
					15 = { change_learning = 2 }
					10 = { change_learning = 4 }
					 5 = { change_learning = 6 }
					20 = { add_trait = theologian }
					 5 = { add_trait = scholar }
					 5 = { add_trait = mystic }
					 5 = { add_trait = shrewd }
				}

				#If we have a wonder upgrade with "inpires_learning" flag, the priest will be better
				if = {
					limit = { ROOT = { realm_wonder_or_upgrade_has_flag_inspires_learning_trigger = yes } }
					random_list = { 
						15 = { add_trait = scholar change_learning = 1 }
						10 = { add_trait = scholar change_learning = 2 }
						 5 = { add_trait = scholar change_learning = 3 }
						10 = { add_trait = erudite }
						10 = { add_trait = physician }
						10 = { add_trait = scholarly_theologian }
						10 = { add_trait = mastermind_theologian }
					}
					random_list = {
						50 = {  } # Nothing
						10 = { add_trait = genius }
						10 = { add_trait = chaste }
						10 = { add_trait = poet }
						10 = { add_trait = proud }
						10 = { add_trait = humble }
					}
				}

				hidden_tooltip = {
					if = {
						limit = {
							ROOT = { religion = yarsan }
						}
						add_trait = yarsan_sayyid
					}
				}
				save_event_target_as = invited_character
			}
			character_event = { id = NE.1 }
		}
		revoke_allowed = {
			always = no
		}
	}

}