﻿
#convert_whole_realm_to_feudalism_decision
#decision_declare_bloodline_holy
#decision_strenghten_bloodline
#decision_dynasty_of_many_crowns
#decision_accept_cannibalism
#decision_found_university
#decision_lunatic_building
#decision_found_witch_coven
#decision_found_kingdom
#decision_found_empire
#repay_loan_decision
#adopt_special_succession_decision
#escape_from_prison_decision

#convert_to_feudalism_decision = { #by Mathilda Bjarnehed
#	picture = "gfx/interface/illustrations/decisions/adopt_feudal.dds"
#	major = yes
#	desc = convert_to_feudalism_decision_desc
#	
#	ai_check_interval = 36
#	
#	is_shown = {
#		has_government = tribal_government
#	}
#	
#	is_valid = {
#		has_realm_law = tribal_authority_3
#		custom_description = {
#			text = faith_is_reformed
#			subject = root
#			faith = { NOT = { has_doctrine_parameter = unreformed } }
#		}
#		prestige_level = 5
#	}
#	
#	cost = {
#		prestige = 150
#	}
#	
#	effect = {
#		change_government = feudal_government
#		trigger_event = major_decisions.0001
#		add_realm_law_skip_effects = crown_authority_0
#	}
#	
#	ai_potential = {
#		#always = yes
#	}
#	
#	ai_will_do = {
#		base = 100
#		modifier = { #Go for the more lenient decision if this is the case
#			add = -100
#			liege = { has_government = feudal_government }
#		}
#	}
#}

#A more lenient decision to convert if your liege is feudal
convert_to_feudalism_liege_converted_decision = { #by Linnéa Thimrén
	picture = "gfx/interface/illustrations/decisions/decision_realm.dds"
	major = yes
	desc = convert_to_feudalism_liege_converted_decision_desc

	ai_check_interval = 36

	is_shown = {
		has_government = tribal_government
		liege = {
			OR = {
				has_government = feudal_government
				has_government = clan_government
			}
		}
	}

	is_valid = {
		OR = {
			has_realm_law = tribal_authority_1
			has_realm_law = tribal_authority_2
			has_realm_law = tribal_authority_3
		}
		custom_description = {
			text = faith_is_reformed
			subject = root
			faith = { NOT = { has_doctrine_parameter = unreformed } }
		}
	}

	cost = {
		prestige = 150
	}

	effect = {
		trigger_event = major_decisions.0001
		save_scope_as = actor
		convert_whole_realm_to_feudalism_effect = yes
		hidden_effect = {
			every_vassal = {
				trigger_event = {
					id = major_decisions.0002
					days = 3
				}
			}
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

#A decision to feudalize the entire realm (wow!)
convert_whole_realm_to_feudalism_decision = { #by Linnéa Thimrén
	picture = "gfx/interface/illustrations/decisions/convert_whole_realm_to_feudalism.dds"
	major = yes
	desc = convert_whole_realm_to_feudalism_decision_desc

	ai_check_interval = 36

	is_shown = {
		has_government = tribal_government
		OR = {
			is_independent_ruler = yes
			AND = {
				is_independent_ruler = no
				liege = {
					NOR = {
						has_government = feudal_government
						has_government = clan_government
					}
				}
			}
		}
	}

	is_valid = {
		has_realm_law = tribal_authority_3
		custom_description = {
			text = faith_is_reformed
			subject = root
			faith = { NOT = { has_doctrine_parameter = unreformed } }
		}
		prestige_level >= 2
		capital_province.county = {
			development_level >= convert_to_feudalism_development_requirement
		}

		custom_description = { #You need to have ALL (non-regional/unique) tribal innovations!
			text = has_all_tribal_innovations
			subject = root.culture
			culture = {
				has_innovation = innovation_motte
				has_innovation = innovation_catapult
				has_innovation = innovation_barracks
				has_innovation = innovation_mustering_grounds
				has_innovation = innovation_bannus
				has_innovation = innovation_quilted_armor
				has_innovation = innovation_gavelkind
				has_innovation = innovation_crop_rotation
				has_innovation = innovation_city_planning
				has_innovation = innovation_casus_belli
				has_innovation = innovation_plenary_assemblies
				has_innovation = innovation_ledger
			}
		}
	}

	cost = {
		prestige = 200
	}

	effect = {
		trigger_event = major_decisions.0001
		save_scope_as = actor
		convert_whole_realm_to_feudalism_effect = yes
		hidden_effect = {
			every_vassal = {
				trigger_event = {
					id = major_decisions.0002
					days = 3
				}
			}
		}
	}

	ai_potential = {
		NOT = { has_title = title:e_mongol_empire } #Stop the Mongols from slowing their conquest.
	}

	ai_will_do = {
		base = 100
	}
}

declare_bloodline_holy_decision = {
	picture = "gfx/interface/illustrations/decisions/declare_bloodline_holy.dds"
	major = yes
	desc = declare_bloodline_holy_decision_desc

	ai_check_interval = 120

	is_shown = {
		is_lowborn = no
		highest_held_title_tier >= 3 #Dukes and higher.
		NOT = { #Just once per Faith.
			faith = {
				exists = var:variable_savior_found
			}
		}
		NOR = {
			has_trait = saoshyant
			has_trait = saoshyant_descendant
			has_trait = sayyid
			has_trait = blood_of_prophet
			has_trait = savior
			has_trait = divine_blood
			has_trait = paragon
			has_trait = consecrated_blood
			faith.religion = faith:ashari.religion #Uses Sayyid mechanics already.
			faith.religion = faith:mazdayasna.religion #Must aim to become Saoshyant instead.
			dynasty = {
				exists = var:variable_made_bloodline_holy
			}
		}
		OR = { #Should not be available to non-Temporal religious heads.
			root.faith = { has_doctrine = doctrine_temporal_head }
			NOT = { root = root.faith.religious_head }
		}
		OR = {  #Either headless faith, religious head himself, or in good relations with other religious head.
			root.faith = { has_doctrine = doctrine_no_head }
			AND = {
				faith = { has_doctrine = doctrine_temporal_head } #Should not be available for the Pope and such.
				root = root.faith.religious_head
			}
			AND = {
				exists = root.faith.religious_head
				NOT = { root = root.faith.religious_head }
			}
		}
	}

	is_valid = {
		trigger_if = {
			limit = {
				exists = root.faith.religious_head
				NOT = { root = root.faith.religious_head }
			}
			root.faith.religious_head = {
				opinion = {
					target = root
					value >= 75
				}
			}
		}
		custom_description = {
			text = faith_is_reformed
			subject = root
			faith = { NOT = { has_doctrine_parameter = unreformed } }
		}
		custom_description = {
			text = "consecrate_bloodline_holy_site"
			faith = {
				any_holy_site = {
					OR = {
						county.holder = root
						county.holder.top_liege = { this = root }
					}
					count >= 1
				}
			}
		}
		piety_level >= 5
		piety >= 2500
	}
	
	is_valid_showing_failures_only = {
		NOR = {
			has_trait = content
			has_trait = humble
		}	
	}

	cost = {
		piety = 2500
	}

	effect = {
		trigger_event = major_decisions.0100
		show_as_tooltip = {
			declare_bloodline_holy_decision_effect = yes
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

strengthen_bloodline_decision = { #by Mathilda Bjarnehed
	picture = "gfx/interface/illustrations/decisions/strengthen_bloodline.dds"
	major = yes
	desc = strengthen_bloodline_decision_desc

	ai_check_interval = 120

	is_shown = {
		is_lowborn = no
		NOT = {
			dynasty = {
			 	has_dynasty_modifier = strong_blood
			}
		}
		OR = {
			has_trait = intellect_good
			has_trait = beauty_good
			has_trait = physique_good
			any_child = {
				dynasty = root.dynasty
				OR = {
					has_trait = intellect_good
					has_trait = beauty_good
					has_trait = physique_good
				}
			}
			AND = {
				exists = player_heir
				player_heir = {
					OR = {
						has_trait = intellect_good
						has_trait = beauty_good
						has_trait = physique_good
					}
				}
			}
		}
	}

	is_valid = {
		is_dynast = yes
		has_trait = intellect_good
		has_trait = beauty_good
		has_trait = physique_good
		OR = {
			has_trait = intellect_good_3
			has_trait = beauty_good_3
			has_trait = physique_good_3
		}
		num_of_bad_genetic_traits = 0
	}

	effect = {
		show_as_tooltip = {
			strengthen_bloodline_decision_effects = yes
		}

		trigger_event = major_decisions.0500

		every_player = {
			limit = {
				NOT = {
					this = root
				}
				dynasty = root.dynasty
			}
			send_interface_toast = {
				title = strengthen_bloodline_decision
				show_as_tooltip = {
					strengthen_bloodline_decision_effects = yes
				}
			}
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}	

dynasty_of_many_crowns_decision = { #by Mathilda Bjarnehed
	picture = "gfx/interface/illustrations/decisions/dynasty_of_many_crowns.dds"
	desc = dynasty_of_many_crowns_decision_desc
	major = yes
	ai_check_interval = 120

	is_shown = {
		is_lowborn = no
		NOT = {
			dynasty = {
			 	has_dynasty_modifier = dynasty_of_many_crowns
			}
		}
		highest_held_title_tier >= tier_kingdom
	}

	is_valid = {
		dynasty = {
			any_dynasty_member = {
				count >= 10
				is_independent_ruler = yes
				highest_held_title_tier >= tier_kingdom
			}
		}
	}

	effect = {
		save_scope_as = many_crowns
		show_as_tooltip = {
			dynasty_of_many_crowns_effects = yes
		}

		trigger_event = major_decisions.0501

		every_player = {
			limit = {
				NOT = {
					this = root
				}
				dynasty = root.dynasty
			}
			send_interface_toast = {
				title = dynasty_of_many_crowns
				show_as_tooltip = {
					dynasty_of_many_crowns_effects = yes
				}
			}
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

accept_cannibalism_decision = { #by Linnéa Thimrén
	picture = "gfx/interface/illustrations/decisions/decision_misc.dds"
	major = yes
	ai_check_interval = 0

	desc = accept_cannibalism_decision_desc
	selection_tooltip = accept_cannibalism_decision_tooltip

	is_shown = {
		is_cannibal_trigger = yes
		NOT = { #Snacking on people should be frowned upon
			faith =  {
				has_doctrine_parameter = cannibalism_legal
			}
		}
	}

	is_valid = {
		custom_description = {
			text = accept_cannibalism_decision_custom
			
			AND = { #Your court chaplain should also be a cannibal!
				exists = root.cp:councillor_court_chaplain
				root.cp:councillor_court_chaplain = {
					is_cannibal_trigger = yes
				}
			}
		}
		trigger_if = {
			limit = {
				exists = faith.religious_head
			}
			faith.religious_head = {
				opinion = {
					target = root
					value >= 40
				}
			}
		}
		piety >= major_piety_value
	}

	is_valid_showing_failures_only = {
		is_ruler = yes
		is_available_adult = yes
	}

	effect = {
		save_scope_as = cannibal
		root.cp:councillor_court_chaplain = {
			save_scope_as = court_chaplain
		}
		show_as_tooltip = {
			accept_cannibalism_decision_effect = yes
		}

		trigger_event = major_decisions.1001
		every_player = {
			limit = {
				NOT = { this = root }
				faith = root.faith
			}
			trigger_event = major_decisions.1002
		}
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}

found_university_decision = {
	picture = "gfx/interface/illustrations/decisions/found_university.dds"
	major = yes
	ai_check_interval = 0

	desc = found_university_decision_desc
	selection_tooltip = found_university_decision_tooltip

	is_shown = {
		highest_held_title_tier >= tier_duchy
		any_sub_realm_barony = {
			OR = { #A place where universities historically existed early
				this = title:b_fes
				this = title:b_cairo
				this = title:b_bologna
				this = title:b_salamanca
				this = title:b_madrid
				this = title:b_oxford
				this = title:b_cambridge
				this = title:b_padua
				this = title:b_siena
				this = title:b_coimbra
				this = title:b_napoli
				this = title:b_tirakka
			}
			title_province = {
				NOR = {
					exists = var:university
					has_building = al_azhar_university
					has_building = sankore_university
					has_building = nalanda_university
				}
			}
		}
	}

	is_valid = {
		prestige_level >= 4

		OR = {
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_fes }
					title:b_fes.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_fes.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_fes.title_province = { has_special_building_slot = no }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_cairo }
					title:b_cairo.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_cairo.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_cairo.title_province = { has_special_building_slot = no }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_bologna }
					title:b_bologna.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_bologna.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_bologna.title_province = { has_special_building_slot = no }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_salamanca }
					title:b_salamanca.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_salamanca.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_salamanca.title_province = { has_special_building_slot = no }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_madrid }
					title:b_madrid.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_madrid.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_madrid.title_province = { has_special_building_slot = no }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_oxford }
					title:b_oxford.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_oxford.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_oxford.title_province = { has_special_building_slot = no }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_cambridge }
					title:b_cambridge.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_cambridge.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_cambridge.title_province = { has_special_building_slot = no }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_padua }
					title:b_padua.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_padua.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_padua.title_province = { has_special_building_slot = no }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_siena }
					title:b_siena.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_siena.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_siena.title_province = { has_special_building_slot = no }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_coimbra }
					title:b_coimbra.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_coimbra.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_coimbra.title_province = { has_special_building_slot = no }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_napoli }
					title:b_napoli.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_napoli.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_napoli.title_province = { has_special_building_slot = no }
					}
				}
			}
			trigger_if = {
				limit = {
					any_sub_realm_barony = { this = title:b_tirakka }
					title:b_tirakka.title_province = { NOT = { exists = var:university } }
				}
				AND = {
					title:b_tirakka.county = { development_level >= medium_development_level }
					custom_description = {
						text = no_special_building_slot
						title:b_tirakka.title_province = { has_special_building_slot = no }
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_ruler = yes
		is_available_adult = yes
	}

	effect = {
		save_scope_as = founder

		show_as_tooltip = { found_university_decision_effect = yes }

		trigger_event = major_decisions.2001
		every_player = {
			limit = {
				NOT = { this = root }
				is_within_diplo_range = { CHARACTER = root }
			}
			trigger_event = major_decisions.2002
		}
	}

	cost = {
		prestige = medium_prestige_value
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}

lunatic_building_decision = { #by Linnéa Thimrén
	picture = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	major = yes
	ai_check_interval = 0

	desc = lunatic_building_decision_desc
	selection_tooltip = lunatic_building_decision_tooltip

	is_shown = {
		has_trait = lunatic
		has_character_flag = glass_dream
		is_landed = yes
		exists = capital_province
		NOT = {
			is_target_in_global_variable_list = {
				name = unavailable_unique_decisions
				target = flag:lunatic_building_decision
			}
		}
	}

	is_valid = {
		prestige_level >= 2
	}

	is_valid_showing_failures_only = {
		is_ruler = yes
		is_available_adult = yes
	}

	effect = {
		save_scope_as = builder
		root.cp:councillor_court_chaplain = {
			save_scope_as = court_chaplain
		}
		show_as_tooltip = { lunatic_building_decision_effect = yes }

		trigger_event = major_decisions.3001
		every_player = {
			limit = {
				NOT = { this = root }
				is_within_diplo_range = { CHARACTER = root }
			}
			trigger_event = major_decisions.3002
		}
		#Can only happen once
		add_to_global_variable_list = {
			name = unavailable_unique_decisions
			target = flag:lunatic_building_decision
		}
	}

	cost = {
		gold = massive_gold_value
		prestige = medium_prestige_gain
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}

found_witch_coven_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_personal_religious.dds"
	major = yes
	ai_check_interval = 0
	desc = found_witch_coven_decision_desc

	is_shown = {
		OR = {
			has_trait = witch
			any_secret = { secret_type = secret_witch }
		}
		exists = house
		NOT = { house = { has_house_modifier = witch_coven } }
	}

	is_valid = {
		is_house_head = yes
		trigger_if = {
			limit = {
				exists = player_heir
				player_heir = {
					is_child_of = root
					house = root.house
				}
			}
			player_heir = {
				is_witch_known_by_trigger = { CHARACTER = root }
			}
		}
		#We want a certain % to be witches but also a minimum amount. So if the house is small, we use a minimum number, and if the house is larger we use %
		trigger_if = {
			limit = {
				house = {
					any_adult_house_member = {
						always = yes
						count <= 6
					}
				}
			}
			house = {
				any_adult_house_member = {
					count >= 4
					is_witch_known_by_trigger = { CHARACTER = root }
				}
			}
		}
		trigger_else = {
			house = {
				any_adult_house_member = {
					percent >= 0.6
					is_witch_known_by_trigger = { CHARACTER = root }
				}
			}
		}
	}

	is_valid_showing_failures_only = {
	}

	effect = {
		found_witch_coven_decision_effects = yes
	}
}

found_kingdom_decision = {
	picture = "gfx/interface/illustrations/decisions/found_kingdom.dds"
	major = yes
	ai_check_interval = 60
	desc = found_kingdom_decision_desc

	is_shown = {
		highest_held_title_tier = tier_duchy
		NOT = { has_game_rule = off_custom_kingdoms }
	}

	is_valid = {
		prestige_level >= 3
		is_independent_ruler = yes
		OR = {
			custom_description = {
				text = found_kingdom_decision_three_duchies_held
				any_held_title = {
					count > 2
					tier = tier_duchy
				}
			}
			sub_realm_size >= 30
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		is_at_war = no
	}

	cost = {
		gold = 300
		prestige = 500
		piety = 200
	}

	effect = {
		create_custom_kingdom_effect = yes
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

found_empire_decision = {
	picture = "gfx/interface/illustrations/decisions/found_empire.dds"
	major = yes
	ai_check_interval = 60
	desc = found_empire_decision_desc

	is_shown = {
		highest_held_title_tier = tier_kingdom
		OR = {
			is_independent_ruler = yes
			any_held_title = {
				count >= 3
				tier = tier_kingdom
			}
		}
		NOT = { has_game_rule = off_custom_kingdoms }
	}

	is_valid = {
		prestige_level >= 4
		OR = {
			sub_realm_size >= 120
			AND = {
				custom_description = {
					text = found_empire_decision_three_kingdoms_held
					any_held_title = {
						count >= 3
						tier = tier_kingdom
					}
				}
				sub_realm_size >= 80
			}
		}
	}

	is_valid_showing_failures_only = {
		is_independent_ruler = yes
		is_available_adult = yes
		is_at_war = no
	}

	cost = {
		gold = 1200
		prestige = 2000
		piety = 600
	}

	effect = {
		create_custom_empire_effect = yes
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

repay_loan_decision = { #by Linnéa Thimrén
	picture = "gfx/interface/illustrations/decisions/decision_misc.dds"

	major = yes

	desc = repay_loan_decision_decision_desc
	selection_tooltip = repay_loan_decision_decision_tooltip

	ai_check_interval = 0

	is_shown = {
		trigger_if = {
			limit = {
				has_character_flag = borrow_from_holy_order
			}
			faith = {
				any_faith_holy_order = { #Your faith must have a Holy Order
					leader = {
						exists = var:owes_me_money
						var:owes_me_money = root
					}
				}
			}
		}
		exists = var:loan_amount_owed
		exists = var:loan_holder
	}

	is_valid_showing_failures_only = {
		is_available = yes
		gold >= var:loan_amount_owed
	}

	effect = {
		pay_short_term_gold = {
			gold = var:loan_amount_owed
			target = var:loan_holder
		}
		if = {
			limit = {
				faith = {
					any_faith_holy_order = {
						leader = {
							this = root.var:loan_holder
						}
					}
				}
			}
			faith = {
				random_faith_holy_order = {
					limit = {
						leader = { this = root.var:loan_holder }
					}
					leader = { save_scope_as = recipient }
					save_scope_as = order
				}
			}
			hidden_effect = { remove_decision_cooldown = repay_loan_decision }
		}
		remove_variable = loan_amount_owed
		remove_variable = loan_holder
		remove_character_flag = borrow_from_holy_order
		if = {
			limit = {
				has_character_flag = promised_repayment
			}
			remove_character_flag = promised_repayment
		}
		if = {
			limit = {
				exists = var:has_reminded_about_loan
			}
			remove_variable = has_reminded_about_loan
		}
		if = {
			limit = {
				exists = var:original_loan_holder
			}
			remove_variable = original_loan_holder
		}
		if = {
			limit = {
				any_vassal = {
					exists = var:owes_me_money
				}
			}
			random_vassal = {
				limit = {
					exists = var:owes_me_money
				}
				save_scope_as = recipient
			}
		}
		scope:recipient = {
			remove_variable = owes_me_money
			remove_variable = loan_amount_owed
			if = {
				limit = {
					exists = var:original_lender
				}
				remove_variable = original_lender
			}
		}
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}

#Adopt special succession type.
adopt_special_succession_decision = { #by Ewan Cowhig Croft
	picture = "gfx/interface/illustrations/decisions/adopt_special_succession.dds"
	major = yes
	desc = adopt_special_succession_decision_desc

	ai_check_interval = 36

	is_shown = {
		OR = {	#Must be eligible for a special succession type.
			special_succession_witengamot_trigger = yes
			special_succession_thing_trigger = yes
			special_succession_tanistry_trigger = yes
		}
		AND = {
			highest_held_title_tier >= tier_kingdom
			has_realm_law_flag = partition_succession_law
			any_held_title = {
				tier >= tier_kingdom
				NOR = {
					has_title_law_flag = advanced_succession_law
					has_title_law_flag = elective_succession_law
				}
			}
		}
		current_date < 1100.1.1	#Curtail special succession types as the centuries wear on. Ever on.
	}

	is_valid = {
		highest_held_title_tier >= tier_kingdom
		any_held_title = {
			tier >= tier_kingdom
			NOR = {
				custom_description = {
					text = found_kingdom_decision_advanced_succesion
					has_title_law_flag = advanced_succession_law
				}
				custom_description = {
					text = found_kingdom_decision_elective_succesion
					has_title_law_flag = elective_succession_law
				}
			}
		}
	}

	cost = {
		prestige = 300
	}

	effect = {
		show_as_tooltip = {
			custom_tooltip = adopt_special_succession_decision_effects.tt
		}
		trigger_event = major_decisions.3100
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 100
	}
}

escape_from_prison_decision = { #by Linnéa Thimrén
	picture = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	major = yes
	desc = escape_from_prison_decision_desc
	selection_tooltip = escape_from_prison_decision_tooltip

	ai_check_interval = 0

	cooldown = { days = 1825 }

	is_shown = {
		is_imprisoned = yes
	}

	is_valid_showing_failures_only = {
		#is_available = yes
		age >= 10
	}

	effect = {
		imprisoner = {
			save_scope_as = imprisoner
		}
		show_as_tooltip = {
			random_list = {
				50 = {
					show_chance = no
					desc = escape_from_prison_decision_success.tt
					release_from_prison = yes
				}
				50 = {
					show_chance = no
					desc = escape_from_prison_decision_failure.tt
					custom_tooltip = escape_from_prison_decision_failure_outcome.tt
				}
			}
		}
		custom_tooltip = escape_from_prison_decision_effect_tooltip
		trigger_event = {
			on_action = escape_from_prison
		}
	}
	
	ai_potential = {
		always = no
	}

	ai_will_do = {
		base = 0
	}
}

tribal_challenge_ruler_decision = { #by Linnéa Thimrén
	picture = "gfx/interface/illustrations/decisions/decision_destiny_goal.dds"
	major = yes
	desc = tribal_challenge_ruler_decision_desc
	selection_tooltip = tribal_challenge_ruler_decision_tooltip

	ai_check_interval = 36

	cooldown = { days = 3650 }

	is_shown = {
		has_government = tribal_government
		exists = liege
		liege = {
			NOT = { this = root }
			has_government = tribal_government
			exists = primary_title
			primary_title = {
				save_temporary_scope_as = title_check
			}
		}
		has_claim_on = scope:title_check
	}

	is_valid_showing_failures_only = {
		is_adult = yes
		liege = {
			is_available = yes
		}
		custom_description = {
			text = recently_took_tribal_challenge_ruler_decision
			subject = root
			NOT = { has_character_flag = recently_took_the_tribal_challenge_ruler_decision }
		}
	}

	effect = {
		save_scope_as = challenger

		add_character_flag = { #To enable the event and block the decision
			flag = recently_took_the_tribal_challenge_ruler_decision
			years = 10
		}

		liege = {
			save_scope_as = liege_to_challenge
			primary_title = {
				save_scope_as = title_being_fought_over
			}
			trigger_event = tribal.1001
		}

		custom_tooltip = tribal_challenge_ruler_effect_tooltip
		show_as_tooltip = {
			random_list = {
				10 = {
					show_chance = no
					desc = tribal_challenge_ruler_desc_success
					tribal_1001_transfer_liege_title_effect = yes
				}
				10 = {
					show_chance = no
					desc = tribal_challenge_ruler_desc_failure
					tribal_1001_challenger_lost_effect = yes
				}
			}
		}
	}
	
	ai_potential = { #Strict restrictions on the ai so they don't go challenge people all the time
		highest_held_title_tier > tier_barony
		has_trait = ambitious
	}

	ai_will_do = {
		base = 0

		ai_value_modifier = {
			ai_greed = 0.25
		}

		opinion_modifier = {
			opinion_target = liege
			multiplier = -1
		}

		modifier = {
			add = 25
			has_trait = ambitious
		}

		modifier = { #Unlikely towards players since it can be such a disruptive force
			add = -50
			liege = { is_ai = no }
		}
	}
}