#decisions = {
	
#	#ai stealing chain
#	ai_steal_artifact = {
#		only_playable = yes
#		is_high_prio = yes
#		
#		potential = {
#			ai = yes
#			NOT = { has_game_rule = { name = ai_stealing value = off } }
#			OR = {
#				AND = {
#					tier = COUNT
#					has_game_rule = { name = ai_stealing value = default }
#					OR = {
#						dynastic_prestige >= 300
#						num_of_titles >= 3
#					}
#				}
#				higher_tier_than = count
#				is_patrician = yes
#			}
#			OR = {
#				trait = ambitious
#				trait = greedy
#				trait = envious
#				prestige = 500
#			}
#			NOR = {
#				primary_title = { temporary = yes } 
#				trait = slow
#				trait = content
#				has_character_flag = stole_artifact
#			}
#		}
#		allow = {
#			war = no
#			has_regent = no
#			is_inaccessible_or_incapable_trigger = no
#			age = 18
#			age < 50
#			prestige = 200
#			NOT = { has_character_flag = do_not_disturb }
#		}
#		effect = { character_event = { id = aao.300 } }
#		ai_will_do = { factor = 1 }
#		ai_check_interval = 48
#	}
#}

targeted_decisions = {
	
	#taking other artifacts
	steal_artifact = {
		
		ai = no
		third_party = ROOT
		third_party_filter = artifacts
		show_third_party_potential = yes
		
		from_potential = { ai = no }
		potential = { num_of_artifacts = 1 }
		third_party_potential = {
			FROMFROM = {
				show_scope_change = no
				is_stealable_trigger = yes
			}
		}
		allow = {
			FROM = {
				is_inaccessible_or_incapable_trigger = no
				has_regent = no
				war = no
				custom_tooltip = {
					text = steal_artifact_allow
					NOR = { 
						has_character_flag = active_heist 
						has_character_modifier = active_heist
					}
				}
				custom_tooltip = {
					text = steal_artifact_allow2
					NOT = { has_character_modifier = steal_artifact_timer }
				}
			}
			ROOT = {
				is_within_diplo_range = FROM
				in_seclusion = no
				NOT = { has_non_aggression_pact_with = FROM }
				OR = {
					is_landed = yes
					mercenary = yes
					holy_order = yes
					controls_religion = yes
				}
			}
		}
		effect = {
			ROOT = { 
				save_event_target_as = target_character 
				any_realm_character = {
					limit = {
						liege = { character = ROOT }
						has_minor_title = title_treasury_guard
					}
					save_event_target_as = target_guard
				}
			}
			FROMFROM = { 
				set_artifact_flag = targeted 
				save_event_target_as = target_artifact
			}
			FROM = {
				set_character_flag = active_heist
				character_event = { id = aao.001 }
			}
		}
	}
	
	#taking back owned artifacts
	retrieve_artifact = {
		
		only_playable = yes
		ai_target_filter = court
		third_party_filter = artifacts
		ai_third_party_filter = artifacts
		third_party = ROOT
		
		from_potential = { is_playable = yes }
		potential = {
			num_of_artifacts = 1
			any_artifact = { any_artifact_owner = { dynasty = FROM } }
		}
		third_party_potential = { 
			FROMFROM = {
				any_artifact_owner = {
					OR = {
						character = FROM 
						dynasty = FROM
					}
				}
			}
		}
		allow = {
			ROOT = {
				custom_tooltip = {
					text = retrieve_artifact_allow
					prisoner = yes
					host = { character = FROM }
				}
			}
			FROM = {
				is_incapable = no
				prisoner = no
			}
		}
		effect = {
			FROM = {
				show_scope_change = no
				ROOT = {
					show_scope_change = no
					FROMFROM = { 
						transfer_artifact = {
							from = PREV
							to = PREVPREV
						}
					}
				}	
			}
			imprison = no
		}
	}

	#taking equipped artifacts
	seize_artifact = {
		
		only_playable = yes
		ai_target_filter = court
		third_party_filter = artifacts
		ai_third_party_filter = artifacts
		third_party = ROOT
		show_third_party_potential = yes
		
		from_potential = { is_playable = yes }
		potential = { num_of_artifacts = 1 }
		third_party_potential = {
			FROMFROM = { 
				show_scope_change = no
				is_artifact_equipped = yes
				NOR = {
					custom_tooltip = { text = seize_artifact_allow has_artifact_flag = blacklist }
					custom_tooltip = { text = steal_artifact_allow2 has_artifact_flag = alive }
				}
			}
		}
		allow = {
			FROM = {
				is_incapable = no
				prisoner = no
			}
			ROOT = {
				custom_tooltip = {
					text = seize_artifact_allow3
					prisoner = yes
					host = { character = FROM }
				}
			}
		}
		effect = {
			FROM = {
				ROOT = {
					show_scope_change = no
					FROMFROM = {
						transfer_artifact = {
							from = PREV
							to = PREVPREV
						}
					}
				}
				custom_tooltip = {
					text = seize_artifact_effect2
					any_vassal = { opinion = { who = FROM modifier = opinion_seized_artifact_tyranny } }
				}
			}
			custom_tooltip = {
				text = seize_artifact_effect3
				ROOT = {
					opinion = { who = FROM modifier = seized_artifact }
					add_rival = FROM
					current_heir = { opinion = { who = FROM modifier = seized_artifact_inheritance } }
					any_dynasty_member = {
						limit = { is_alive = yes }
						opinion = { who = FROM modifier = seized_artifact_dynastic }
					}
				}
			}
			imprison = no
		}
	}
}

#title_decisions = { #Disabled because the Steam comments said it had a noticeable performance impact
#	
#	##AI vault building
#	ai_build_vault = {
#		only_playable = yes
#		
#		filter = capital
#		ai_target_filter = capital
#		
#		potential = {
#			FROM = {
#				has_game_rule = { name = aao_vaults value = on }
#				ai = yes
#				num_of_artifacts >= 1 
#				trigger_if = { #MRs are inconsistent with their "capitals" this is to make sure only the palace is valid
#					limit = { 
#						OR = {
#							is_merchant_republic = yes
#							is_patrician = yes
#						}
#					}
#					ROOT = { holding_type = family_palace }
#				}
#				trigger_else = { capital_holding = { title = ROOT } }
#			}
#			NOR = {
#				has_building = ca_vault_3
#				has_building = ct_vault_3
#				has_building = tp_vault_3
#				has_building = fp_avault_3
#				has_building = tb_vault_3
#				has_building = no_vault_3
#			}
#		}
#		allow = {
#			trigger_if = {
#				limit = { 
#					NOR = {
#						has_building = ca_vault_1
#						has_building = ct_vault_1
#						has_building = tp_vault_1
#						has_building = fp_avault_1
#						has_building = tb_vault_1
#						has_building = no_vault_1
#					}
#				}
#				trigger_if = {
#					limit = {
#						FROM = { 
#							is_tribal = no
#							is_nomadic = no
#						}
#					}
#					FROM = { wealth = 200 }
#				}
#				trigger_else = { FROM = { wealth = 100 } }
#				OR = {
#					FROM = { TECH_FORTIFICATIONS_CONSTRUCTION = 1 }
#					location = { TECH_FORTIFICATIONS_CONSTRUCTION = 1 }
#				}
#			}
#			trigger_else_if = {
#				limit = { 
#					OR = {
#						has_building = ca_vault_1
#						has_building = ct_vault_1
#						has_building = tp_vault_1
#						has_building = fp_avault_1
#						has_building = tb_vault_1
#						has_building = no_vault_1
#					}
#					NOR = {
#						has_building = ca_vault_2
#						has_building = ct_vault_2
#						has_building = tp_vault_2
#						has_building = fp_avault_2
#						has_building = tb_vault_2
#						has_building = no_vault_2
#					}
#				}
#				trigger_if = {
#					limit = {
#						FROM = { 
#							is_tribal = no
#							is_nomadic = no
#						}
#					}
#					FROM = { wealth = 300 }
#				}
#				trigger_else = { FROM = { wealth = 200 } }
#				OR = {
#					FROM = { TECH_FORTIFICATIONS_CONSTRUCTION = 3 }
#					location = { TECH_FORTIFICATIONS_CONSTRUCTION = 3 }
#				}
#			}
#			trigger_else = {
#				trigger_if = {
#					limit = {
#						FROM = { 
#							is_tribal = no
#							is_nomadic = no
#						}
#					}
#					FROM = { wealth = 400 }
#				}
#				trigger_else = { FROM = { wealth = 300 } }
#				OR = {
#					FROM = { TECH_FORTIFICATIONS_CONSTRUCTION = 5 }
#					location = { TECH_FORTIFICATIONS_CONSTRUCTION = 5 }
#				}
#			}
#		}
#		
#		effect = {
#			if = {
#				limit = { 
#					NOR = {
#						has_building = ca_vault_1
#						has_building = ct_vault_1
#						has_building = tp_vault_1
#						has_building = fp_avault_1
#						has_building = tb_vault_1
#						has_building = no_vault_1
#					}
#				}
#				if = {
#					limit = {
#						FROM = { 
#							is_tribal = no
#							is_nomadic = no
#						}
#					}
#					FROM = { wealth = -200 }
#				}
#				else = { FROM = { wealth = -100 } }
#				
#				trigger_switch = {
#					on_trigger = holding_type
#					
#					castle = { add_building = ca_vault_1 }
#					city = { add_building = ct_vault_1 }
#					temple = { add_building = tp_vault_1 }
#					family_palace = { add_building = fp_avault_1 }
#					tribal = { add_building = tb_vault_1 }
#					nomad = { add_building = no_vault_1 }
#				}
#			}
#			else_if = {
#				limit = { 
#					OR = {
#						has_building = ca_vault_1
#						has_building = ct_vault_1
#						has_building = tp_vault_1
#						has_building = fp_avault_1
#						has_building = tb_vault_1
#						has_building = no_vault_1
#					}
#					NOR = {
#						has_building = ca_vault_2
#						has_building = ct_vault_2
#						has_building = tp_vault_2
#						has_building = fp_avault_2
#						has_building = tb_vault_2
#						has_building = no_vault_2
#					}
#				}
#				if = {
#					limit = {
#						FROM = { 
#							is_tribal = no
#							is_nomadic = no
#						}
#					}
#					FROM = { wealth = -300 }
#				}
#				else = { FROM = { wealth = -200 } }
#				
#				trigger_switch = {
#					on_trigger = holding_type
#					
#					castle = { add_building = ca_vault_2 }
#					city = { add_building = ct_vault_2 }
#					temple = { add_building = tp_vault_2 }
#					family_palace = { add_building = fp_avault_2 }
#					tribal = { add_building = tb_vault_2 }
#					nomad = { add_building = no_vault_2 }
#				}
#			}
#			else = {
#				if = {
#					limit = {
#						FROM = { 
#							is_tribal = no
#							is_nomadic = no
#						}
#					}
#					FROM = { wealth = -400 }
#				}
#				else = { FROM = { wealth = -300 } }
#				
#				trigger_switch = {
#					on_trigger = holding_type
#					
#					castle = { add_building = ca_vault_3 }
#					city = { add_building = ct_vault_3 }
#					temple = { add_building = tp_vault_3 }
#					family_palace = { add_building = fp_avault_3 }
#					tribal = { add_building = tb_vault_3 }
#					nomad = { add_building = no_vault_3 }
#				}
#			}
#		}
#		
#		ai_check_interval = 12
#		ai_will_do = {
#			factor = 1
#		}
#	}
#	
#	
#	ai_remove_vault = { ##nomads and patricians should never use this
#		only_rulers = yes
#		
#		filter = owned
#		ai_target_filter = owned
#		
#		potential = {
#			FROM = {
#				has_game_rule = { name = aao_vaults value = on }
#				ai = yes
#				NOT = { capital_scope = { title = ROOT } } 
#			}
#			OR = {
#				has_building = ca_vault_1
#				has_building = ct_vault_1
#				has_building = tp_vault_1
#				has_building = tb_vault_1
#			}
#		}
#		allow = {
#			OR = {
#				has_building = ca_vault_1
#				has_building = ct_vault_1
#				has_building = tp_vault_1
#				has_building = tb_vault_1
#			}
#		}
#		effect = {
#			remove_building = ca_vault_1
#			remove_building = ct_vault_1
#			remove_building = tp_vault_1
#			remove_building = tb_vault_1
#			remove_building = ca_vault_2
#			remove_building = ct_vault_2
#			remove_building = tp_vault_2
#			remove_building = tb_vault_2
#			remove_building = ca_vault_3
#			remove_building = ct_vault_3
#			remove_building = tp_vault_3
#			remove_building = tb_vault_3
#			
#			FROM = { wealth = 100 }
#		}
#		
#		
#		ai_check_interval = 12
#		ai_will_do = {
#			factor = 1
#		}
#	}
#}
