###########################################
#
# Holy Order Decisions for Sons of Abraham
#
###########################################
# Written by Henrik Fåhraeus
###########################################

# Holy Order Decisions are listed for each existing holy order of the right religion

decisions = {

	expel_the_knights_templar = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_knights_templar
			NOT = { has_character_modifier = expelled_d_knights_templar }
			
			any_realm_province = {
				any_province_lord = {
					d_knights_templar = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_the_knights_templar_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_the_knights_templar_check
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip_b
				hidden_tooltip = {
					character_event = { id = SoA.2990 }
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	expel_the_knights_hospitaler = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_knights_hospitaler
			NOT = { has_character_modifier = expelled_d_knights_hospitaler }
			
			any_realm_province = {
				any_province_lord = {
					d_knights_hospitaler = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_the_knights_hospitaler_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_the_knights_hospitaler_check
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip_b
				hidden_tooltip = {
					character_event = { id = SoA.2990 }
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	expel_the_teutonic_order = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_teutonic_order
			NOT = { has_character_modifier = expelled_d_teutonic_order }
			
			any_realm_province = {
				any_province_lord = {
					d_teutonic_order = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_the_teutonic_order_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_the_teutonic_order_check
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip_b
				hidden_tooltip = {
					character_event = { id = SoA.2990 }
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	expel_the_jomsvikings = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = norse_pagan
				religion = norse_pagan_reformed
			}
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_jomsvikings
			NOT = { has_character_modifier = expelled_d_jomsvikings }
			
			any_realm_province = {
				any_province_lord = {
					d_jomsvikings = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_the_jomsvikings_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_the_jomsvikings_check
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip_b
				hidden_tooltip = {
					character_event = { id = SoA.2990 }
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	expel_the_braedralag = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = norse_pagan
				religion = norse_pagan_reformed
			}
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_braedralag
			NOT = { has_character_modifier = expelled_d_braedralag }
			
			any_realm_province = {
				any_province_lord = {
					d_braedralag = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_the_braedralag_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_the_braedralag_check
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip_b
				hidden_tooltip = {
					character_event = { id = SoA.2990 }
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	expel_the_harii = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = german_pagan
				religion = german_pagan_reformed
			}
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_harii
			NOT = { has_character_modifier = expelled_d_harii }
			
			any_realm_province = {
				any_province_lord = {
					d_harii = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_the_harii_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_the_harii_check
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip_b
				hidden_tooltip = {
					character_event = { id = SoA.2990 }
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	expel_the_assassins = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = shiite
				religion = druze
				religion = hurufi
				religion = bektashi
				religion = quranist
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_hashshashin
			NOT = { has_character_modifier = expelled_d_hashshashin }
			
			any_realm_province = {
				any_province_lord = {
					d_hashshashin = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
			NOT = { society_member_of = the_assassins }
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_the_assassins_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_the_assassins_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_knights_templar = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			is_nomadic = no
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			is_title_active = d_knights_templar
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_knights_templar
				has_landed_title = d_knights_templar
			}
			OR = {
				AND = {
					NOT = { is_title_active = d_teutonic_order }
					NOT = { is_title_active = d_knights_santiago }
					NOT = { is_title_active = d_knights_calatrava }
				}
				AND = {
					NOT = { is_title_active = d_teutonic_order }
					NOT = { culture_group = iberian }
					NOT = { culture_group = west_african }
					NOT = { culture = maghreb_arabic }
					NOT = { culture = occitan }
				}
				AND = {
					NOT = { is_title_active = d_knights_santiago }
					NOT = { is_title_active = d_knights_calatrava }
					NOT = { culture_group = north_germanic }
					NOT = { culture_group = central_germanic }
					NOT = { culture_group = magyar }
					NOT = { culture_group = south_slavic }
					NOT = { culture_group = west_slavic }
				}
			}
			
			has_dlc = "Sons of Abraham"
			
			d_knights_templar = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_knights_templar = {
					holder_scope = {
						character_event = {
							id = SoA.1140
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					AND = {
						NOT = { controls_religion = chalcedonian }
						NOT = { controls_religion = catholic }
						NOT = { controls_religion = fraticelli }
						NOT = { controls_religion = waldensian }
						NOT = { controls_religion = lollard }
					}
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	donate_money_to_knights_hospitaler = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			is_title_active = d_knights_hospitaler
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_knights_hospitaler
				has_landed_title = d_knights_hospitaler
			}
			OR = {
				AND = {
					NOT = { is_title_active = d_teutonic_order }
					NOT = { is_title_active = d_knights_santiago }
					NOT = { is_title_active = d_knights_calatrava }
				}
				AND = {
					NOT = { is_title_active = d_teutonic_order }
					NOT = { culture_group = iberian }
					NOT = { culture_group = west_african }
					NOT = { culture = maghreb_arabic }
					NOT = { culture = occitan }
				}
				AND = {
					NOT = { is_title_active = d_knights_santiago }
					NOT = { is_title_active = d_knights_calatrava }
					NOT = { culture_group = north_germanic }
					NOT = { culture_group = central_germanic }
					NOT = { culture_group = magyar }
					NOT = { culture_group = south_slavic }
					NOT = { culture_group = west_slavic }
				}
			}
			
			has_dlc = "Sons of Abraham"
			
			d_knights_hospitaler = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_knights_hospitaler = {
					holder_scope = {
						character_event = {
							id = SoA.1140
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					AND = {
						NOT = { controls_religion = chalcedonian }
						NOT = { controls_religion = catholic }
						NOT = { controls_religion = fraticelli }
						NOT = { controls_religion = waldensian }
						NOT = { controls_religion = lollard }
					}
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	donate_money_to_teutonic_order = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			is_title_active = d_teutonic_order
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_teutonic_order
				has_landed_title = d_teutonic_order
			}
			OR = {
				AND = {
					NOT = { is_title_active = d_knights_hospitaler }
					NOT = { is_title_active = d_knights_templar }
					NOT = { is_title_active = d_knights_santiago }
					NOT = { is_title_active = d_knights_calatrava }
				}
				AND = {
					NOT = { is_title_active = d_knights_hospitaler }
					NOT = { is_title_active = d_knights_templar }
					NOT = { culture_group = iberian }
					NOT = { culture_group = west_african }
					NOT = { culture = maghreb_arabic }
					NOT = { culture = occitan }
				}
				culture_group = north_germanic
				culture_group = central_germanic
				culture_group = magyar
				culture_group = south_slavic
				culture_group = west_slavic
			}
			
			has_dlc = "Sons of Abraham"
			
			d_teutonic_order = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_teutonic_order = {
					holder_scope = {
						character_event = {
							id = SoA.1340
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					AND = {
						NOT = { controls_religion = chalcedonian }
						NOT = { controls_religion = catholic }
						NOT = { controls_religion = fraticelli }
						NOT = { controls_religion = waldensian }
						NOT = { controls_religion = lollard }
					}
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	donate_money_to_jomsvikings = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = norse_pagan
				religion = norse_pagan_reformed
			}
			is_title_active = d_jomsvikings
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_jomsvikings
				has_landed_title = d_jomsvikings
			}
			has_dlc = "Sons of Abraham"
			d_jomsvikings = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_jomsvikings = {
					holder_scope = {
						character_event = {
							id = SoA.1540
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	donate_money_to_braedralag = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = norse_pagan
				religion = norse_pagan_reformed
			}
			is_title_active = d_braedralag
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_braedralag
				has_landed_title = d_braedralag
			}
			has_dlc = "Sons of Abraham"
			d_braedralag = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_braedralag = {
					holder_scope = {
						character_event = {
							id = SoA.1540
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	donate_money_to_harii = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = german_pagan
				religion = german_pagan_reformed
			}
			is_title_active = d_harii
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_harii
				has_landed_title = d_harii
			}
			has_dlc = "Sons of Abraham"
			d_harii = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_harii = {
					holder_scope = {
						character_event = {
							id = SoA.1540
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	donate_money_to_assassins = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = shiite
				religion = druze
				religion = hurufi
				religion = bektashi
				religion = quranist
			}
			is_heretic = no
			is_title_active = d_hashshashin
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_hashshashin
				has_landed_title = d_hashshashin
			}
			NOT = { society_member_of = the_assassins }
			has_dlc = "Sons of Abraham"
			d_hashshashin = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_hashshashin = {
					holder_scope = {
						character_event = {
							id = SoA.1140
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}

		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
		
	donate_money_to_ansar = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = sunni
				religion = zikri
				religion = quranist
			}
			is_heretic = no
			is_title_active = d_ansar
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_ansar
				has_landed_title = d_ansar
			}
			has_dlc = "Sons of Abraham"
			d_ansar = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_ansar = {
					holder_scope = {
						character_event = {
							id = SoA.1140
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}

		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_the_ansar = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = sunni
				religion = zikri
				religion = quranist
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_ansar
			NOT = { has_character_modifier = expelled_d_ansar }
			any_realm_province = {
				any_province_lord = {
					d_ansar = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_the_ansar_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_the_ansar_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_haruriyyah = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = ibadi
				religion = kharijite
			}
			is_heretic = no
			is_title_active = d_haruriyyah
			has_dlc = "Charlemagne"
			
			NOR = { 
				has_character_modifier = expelled_d_haruriyyah 
				has_character_modifier = donated_to_holy_order
				has_landed_title = d_haruriyyah
			}
			
			d_haruriyyah = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_haruriyyah = {
					holder_scope = {
						character_event = {
							id = SoA.1140
						}
					}
				}
			}
			
			wealth = -300
			piety = 300
		}

		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
		}
	}
	
	expel_the_haruriyyah = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = ibadi
				religion = kharijite
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_haruriyyah
			NOT = { has_character_modifier = expelled_d_haruriyyah }
			
			any_realm_province = {
				any_province_lord = {
					d_haruriyyah = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Charlemagne"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_the_haruriyya_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_the_haruriyya_check
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip_b
				hidden_tooltip = {
					character_event = { id = SoA.2990 }
				}
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	vassalize_knights_templar = {
		is_high_prio = yes
		ai_check_interval = 6
		
		only_playable = yes
		potential = {
			is_playable = yes
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			NOT = { has_character_modifier = expelled_d_knights_templar }
			is_title_active = d_knights_templar
			has_landed_title = k_jerusalem
			has_dlc = "Sons of Abraham"
			d_knights_templar = {
				holder_scope = {
					NOT = { has_truce = ROOT }
					NOT = { reverse_has_truce = ROOT }
					NOT = { has_non_aggression_pact_with = ROOT }
					ai = yes
					independent = yes
					lower_tier_than = KING
					is_heretic = no
					primary_title = { title = d_knights_templar }
					religion = ROOT
				}
			}
		}
		
		allow = {
			war = no
			has_regent = no
			independent = yes
		}
		
		effect = {
			hidden_tooltip = {
				d_knights_templar = {
					holder_scope = {
						character_event = {
							id = SoA.1015
						}
					}
				}
			}
		}
		
		
		ai_will_do = {
			factor = 1
		}
	}
	
	vassalize_knights_hospitaler = {
		is_high_prio = yes
		ai_check_interval = 6
		
		only_playable = yes
		potential = {
			is_playable = yes
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			NOT = { has_character_modifier = expelled_d_knights_hospitaler }
			is_title_active = d_knights_hospitaler
			has_landed_title = k_jerusalem
			has_dlc = "Sons of Abraham"
			d_knights_hospitaler = {
				holder_scope = {
					NOT = { has_truce = ROOT }
					NOT = { reverse_has_truce = ROOT }
					NOT = { has_non_aggression_pact_with = ROOT }
					ai = yes
					independent = yes
					lower_tier_than = KING
					is_heretic = no
					primary_title = { title = d_knights_hospitaler }
					religion = ROOT
				}
			}
		}
		
		allow = {
			war = no
			has_regent = no
			independent = yes
		}
		
		effect = {
			hidden_tooltip = {
				d_knights_hospitaler = {
					holder_scope = {
						character_event = {
							id = SoA.1115
						}
					}
				}
			}
		}
		
		
		ai_will_do = {
			factor = 1
		}
	}
	
	expel_the_holy_sepulchre = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = orthodox
				religion = bogomilist
				religion = monothelite
				religion = iconoclast
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_holy_sepulchre
			NOT = { has_character_modifier = expelled_d_holy_sepulchre }
			
			any_realm_province = {
				any_province_lord = {
					d_holy_sepulchre = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_the_holy_sepulchre_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_the_holy_sepulchre_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_holy_sepulchre = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = orthodox
				religion = bogomilist
				religion = monothelite
				religion = iconoclast
			}
			is_heretic = no
			
			is_title_active = d_holy_sepulchre
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_holy_sepulchre
				has_landed_title = d_holy_sepulchre
			}
			d_holy_sepulchre = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_holy_sepulchre = {
					holder_scope = {
						character_event = {
							id = SoA.1640
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					AND = {
						NOT = { controls_religion = orthodox }
						NOT = { controls_religion = bogomilist }
						NOT = { controls_religion = monothelite }
						NOT = { controls_religion = iconoclast }
					}
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_d_saint_anthony = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = miaphysite
				religion = monophysite
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_saint_anthony
			NOT = { has_character_modifier = expelled_d_saint_anthony }
			
			any_realm_province = {
				any_province_lord = {
					d_saint_anthony = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_d_saint_anthony_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_d_saint_anthony_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_saint_anthony = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = miaphysite
				religion = monophysite
			}
			is_heretic = no
			
			is_title_active = d_saint_anthony
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_saint_anthony
				has_landed_title = d_saint_anthony
			}
			d_saint_anthony = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_saint_anthony = {
					holder_scope = {
						character_event = {
							id = SoA.1740
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					AND = {
						NOT = { controls_religion = miaphysite }
						NOT = { controls_religion = monophysite }
					}
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_immortals = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = zoroastrian
				religion = mazdaki
				religion = zurvanist
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_immortals
			NOT = { has_character_modifier = expelled_d_immortals }
			
			any_realm_province = {
				any_province_lord = {
					d_immortals = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_immortals_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_immortals_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_the_immortals = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = zoroastrian
				religion = mazdaki
				religion = zurvanist
			}
			is_heretic = no
			
			is_title_active = d_immortals

			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_immortals
				has_landed_title = d_immortals
			}
			
			has_dlc = "Sons of Abraham"
			
			d_immortals = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_immortals = {
					holder_scope = {
						character_event = {
							id = SoA.1840
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					AND = {
						NOT = { controls_religion = zoroastrian }
						NOT = { controls_religion = mazdaki }
						NOT = { controls_religion = zurvanist }
					}
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_zealots = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = jewish
				religion = samaritan
				religion = karaite
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_zealots
			NOT = { has_character_modifier = expelled_d_zealots }
			
			any_realm_province = {
				any_province_lord = {
					d_zealots = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_zealots_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_zealots_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_the_zealots = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = jewish
				religion = samaritan
				religion = karaite
			}
			is_heretic = no
			
			is_title_active = d_zealots
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_zealots
				has_landed_title = d_zealots
			}
			has_dlc = "Sons of Abraham"
			d_zealots = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_zealots = {
					holder_scope = {
						character_event = {
							id = SoA.1940
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					AND = {
						NOT = { controls_religion = jewish }
						NOT = { controls_religion = samaritan }
						NOT = { controls_religion = karaite }
					}
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_sky_lords = {
		only_independent = yes
		potential = {
			ai = no
			religion = tengri_pagan_reformed
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_sky_lords
			NOT = { has_character_modifier = expelled_d_sky_lords }
			
			any_realm_province = {
				any_province_lord = {
					d_sky_lords = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_sky_lords_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_sky_lords_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_sky_lords = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			religion = tengri_pagan_reformed
			
			is_title_active = d_sky_lords
	
			has_dlc = "Sons of Abraham"
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_sky_lords
				has_landed_title = d_sky_lords
			}
			d_sky_lords = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_sky_lords = {
					holder_scope = {
						character_event = {
							id = SoA.2040
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					NOT = { controls_religion = tengri_pagan_reformed }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_spirit_guardians = {
		only_independent = yes
		potential = {
			ai = no
			religion = west_african_pagan_reformed
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_spirit_guardians
			NOT = { has_character_modifier = expelled_d_spirit_guardians }
			
			any_realm_province = {
				any_province_lord = {
					d_spirit_guardians = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_spirit_guardians_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_spirit_guardians_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_spirit_guardians = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			religion = west_african_pagan_reformed
			
			is_title_active = d_spirit_guardians
			has_dlc = "Sons of Abraham"
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_spirit_guardians
				has_landed_title = d_spirit_guardians
			}
			d_spirit_guardians = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_spirit_guardians = {
					holder_scope = {
						character_event = {
							id = SoA.2140
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					NOT = { controls_religion = west_african_pagan_reformed }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_warriors_perun = {
		only_independent = yes
		potential = {
			ai = no
			religion = slavic_pagan_reformed
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_warriors_perun
			NOT = { has_character_modifier = expelled_d_warriors_perun }
			
			any_realm_province = {
				any_province_lord = {
					d_warriors_perun = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_warriors_perun_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_warriors_perun_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_warriors_perun = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			religion = slavic_pagan_reformed
			
			is_title_active = d_warriors_perun
			
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_warriors_perun
				has_landed_title = d_warriors_perun
			}
			has_dlc = "Sons of Abraham"
			
			d_warriors_perun = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_warriors_perun = {
					holder_scope = {
						character_event = {
							id = SoA.2240
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					NOT = { controls_religion = slavic_pagan_reformed }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_chosen_perkunas = {
		only_independent = yes
		potential = {
			ai = no
			religion = baltic_pagan_reformed
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_chosen_perkunas
			NOT = { has_character_modifier = expelled_d_chosen_perkunas }
			
			any_realm_province = {
				any_province_lord = {
					d_chosen_perkunas = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_chosen_perkunas_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_chosen_perkunas_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_chosen_perkunas = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			religion = baltic_pagan_reformed
			
			is_title_active = d_chosen_perkunas
	
			has_dlc = "Sons of Abraham"
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_chosen_perkunas
				has_landed_title = d_chosen_perkunas
			}
			d_chosen_perkunas = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_chosen_perkunas = {
					holder_scope = {
						character_event = {
							id = SoA.2340
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					NOT = { controls_religion = baltic_pagan_reformed }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_sons_kaleva = {
		only_independent = yes
		potential = {
			ai = no
			religion = finnish_pagan_reformed
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_sons_kaleva
			NOT = { has_character_modifier = expelled_d_sons_kaleva }
			
			any_realm_province = {
				any_province_lord = {
					d_chosen_perkunas = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_sons_kaleva_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_sons_kaleva_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_sons_kaleva = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			religion = finnish_pagan_reformed
			
			is_title_active = d_sons_kaleva
		
			has_dlc = "Sons of Abraham"
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_sons_kaleva
				has_landed_title = d_sons_kaleva
			}
			d_sons_kaleva = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_sons_kaleva = {
					holder_scope = {
						character_event = {
							id = SoA.2440
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					NOT = { controls_religion = finnish_pagan_reformed }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_huitzilopochtli = {
		only_independent = yes
		potential = {
			ai = no
			religion = aztec
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_huitzilopochtli
			NOT = { has_character_modifier = expelled_d_huitzilopochtli }
			
			any_realm_province = {
				any_province_lord = {
					d_huitzilopochtli = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_huitzilopochtli_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_huitzilopochtli_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_huitzilopochtli = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			religion = aztec
			
			is_title_active = d_huitzilopochtli
			has_dlc = "Sons of Abraham"
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_huitzilopochtli
				has_landed_title = d_huitzilopochtli
			}
			d_huitzilopochtli = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_huitzilopochtli = {
					holder_scope = {
						character_event = {
							id = SoA.2540
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					NOT = { controls_religion = aztec }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_knights_santiago = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_knights_santiago
			NOT = { has_character_modifier = expelled_d_knights_santiago }
			
			any_realm_province = {
				any_province_lord = {
					d_knights_santiago = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_knights_santiago_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_knights_santiago_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_knights_santiago = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			
			is_title_active = d_knights_santiago
			
			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_knights_santiago
				has_landed_title = d_knights_santiago
			}

			OR = {
				AND = {
					NOT = { is_title_active = d_knights_hospitaler }
					NOT = { is_title_active = d_knights_templar }
					NOT = { is_title_active = d_teutonic_order }
				}
				AND = {
					NOT = { is_title_active = d_knights_templar }
					NOT = { is_title_active = d_knights_hospitaler }
					NOT = { culture_group = north_germanic }
					NOT = { culture_group = central_germanic }
					NOT = { culture_group = magyar }
					NOT = { culture_group = south_slavic }
					NOT = { culture_group = west_slavic }
				}
				culture_group = iberian
				culture_group = west_african
				culture = maghreb_arabic
				culture = occitan
			}
			
			has_dlc = "Sons of Abraham"
			
			d_knights_santiago = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_knights_santiago = {
					holder_scope = {
						character_event = {
							id = SoA.2640
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					AND = {
						NOT = { controls_religion = chalcedonian }
						NOT = { controls_religion = catholic }
						NOT = { controls_religion = fraticelli }
						NOT = { controls_religion = waldensian }
						NOT = { controls_religion = lollard }
					}
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_knights_calatrava = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_knights_calatrava
			NOT = { has_character_modifier = expelled_d_knights_calatrava }
			
			any_realm_province = {
				any_province_lord = {
					d_knights_calatrava = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_knights_calatrava_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_knights_calatrava_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_knights_calatrava = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			is_title_active = d_knights_calatrava
			

			NOR = {
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_knights_calatrava
				has_landed_title = d_knights_calatrava
			}

			OR = {
				AND = {
					NOT = { is_title_active = d_knights_hospitaler }
					NOT = { is_title_active = d_knights_templar }
					NOT = { is_title_active = d_teutonic_order }
				}
				AND = {
					NOT = { is_title_active = d_knights_templar }
					NOT = { is_title_active = d_knights_hospitaler }
					NOT = { culture_group = north_germanic }
					NOT = { culture_group = central_germanic }
					NOT = { culture_group = magyar }
					NOT = { culture_group = south_slavic }
					NOT = { culture_group = west_slavic }
				}
				culture_group = iberian
				culture_group = west_african
				culture = maghreb_arabic
				culture = occitan
			}
			
			has_dlc = "Sons of Abraham"
			
			d_knights_calatrava = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_knights_calatrava = {
					holder_scope = {
						character_event = {
							id = SoA.2740
						}
					}
				}
			}
			
			wealth = -300
			piety = 150
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					AND = {
						NOT = { controls_religion = chalcedonian }
						NOT = { controls_religion = catholic }
						NOT = { controls_religion = fraticelli }
						NOT = { controls_religion = waldensian }
						NOT = { controls_religion = lollard }
					}
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_order_of_addai = {
		only_independent = yes
		potential = {
			ai = no
			OR = {
				religion = nestorian
				religion = messalian
			}
			is_heretic = no
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_saint_addai
			NOT = { has_character_modifier = expelled_d_saint_addai }
			
			any_realm_province = {
				any_province_lord = {
					d_saint_addai = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_order_of_addai_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_order_of_addai_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_order_of_addai = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
			is_playable = yes
			OR = {
				religion = nestorian
				religion = messalian
			}
			is_heretic = no
			
			is_title_active = d_saint_addai
			
			NOR = { 
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_saint_addai 
				has_landed_title = d_saint_addai
			}
			
			d_saint_addai = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
			
			has_dlc = "Sons of Abraham"
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_saint_addai = {
					holder_scope = {
						character_event = {
							id = SoA.2840
						}
					}
				}
			}
			
			wealth = -300
			piety = 300
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					AND = {
						NOT = { controls_religion = nestorian }
						NOT = { controls_religion = messalian }
					}
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
			modifier = {
				factor = 0
				has_character_modifier = ai_austerity
			}
		}
	}
	
	expel_zun_warriors = {
		only_independent = yes
		potential = {
			ai = no
			religion = zun_pagan_reformed
			higher_tier_than = DUKE
			independent = yes
			is_title_active = d_zun_warriors
			NOT = { has_character_modifier = expelled_d_zun_warriors }
			
			any_realm_province = {
				any_province_lord = {
					d_zun_warriors = {
						holder_scope = {
							OR = {
								character = PREVPREV
								is_vassal_or_below = PREVPREV
							}
						}
					}
				}
			}
			has_dlc = "Charlemagne"
		}
		
		allow = {
			piety = 1000
			custom_tooltip = {
				text = expelling_holy_order_decision_tooltip
				hidden_tooltip = {
					NOT = { has_character_flag = expel_zun_warriors_check }
				}
			}
		}
		
		effect = {
			set_character_flag = expel_zun_warriors_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_zun_warriors = {
		only_playable = yes
		ai_check_interval = 60
		potential = {
		is_playable = yes
			religion = zun_pagan_reformed
			
			is_title_active = d_zun_warriors
			
			has_dlc = "Charlemagne"
			
			NOR = { 
				has_character_modifier = donated_to_holy_order
				has_character_modifier = expelled_d_zun_warriors 
				has_landed_title = d_zun_warriors
			}
			
			d_zun_warriors = {
				holder_scope = {
					liege = {
						NOT = { character = ROOT }
					}
				}
			}
		}
		
		allow = {
			wealth = 300
		}
		
		effect = {
			if = {
				limit = { 
					NOT = { has_character_modifier = donated_to_holy_order }
				}
				add_character_modifier = {
					name = donated_to_holy_order
					duration = -1
				}
			}
			
			hidden_tooltip = {
				d_zun_warriors = {
					holder_scope = {
						character_event = {
							id = CM.4005
						}
					}
				}
			}
			
			wealth = -300
			piety = 300
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					piety = 1000
					NOT = { wealth = 1000 }
					NOT = { controls_religion = zun_pagan_reformed }
				}
			}
			modifier = {
				factor = 0.12 # Slow it down
			}
		}
	}
}
