﻿## Diplomacy
### Secure Alliances ###
diplomacy_oath_1_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/mpo_decision_confederation.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = diplomacy_oath_1
		has_variable = diplomacy_oath_1_timer
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		save_temporary_scope_as = root_temp_scope
		custom_tooltip = {
			text = custom_alliance_oath_decision_trigger
			any_ally = {
				count >= 3
				highest_held_title_tier >= {
					value = root.highest_held_title_tier
					subtract = 1
				}
				opinion = {
					target = root
					value >= 50
				}
			}
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = diplomacy_oath_1 }

		show_as_tooltip = {
			add_character_modifier = oath_of_alliances
		}

		every_ally = {
			custom = custom_every_allied_ruler
			add_opinion = {
				modifier = respect_opinion
				target = root
				opinion = 20
			}
		}
		every_ally = { # Kept in a separate block from the previous one, so it looks proper in the tooltip
			culture = {
				if = {
					limit = {
						NOR = {
							this = root.culture
							is_in_list = culture_affected
						}
					}
					change_cultural_acceptance = {
						target = root.culture
						value = 10
						desc = culture_acceptance_gain_oath
					}
				}
				add_to_list = culture_affected
			}
		}

		hidden_effect = {
			remove_variable = diplomacy_oath_1_timer
		}
	}

	ai_will_do = {
		base = 100
	}
}

### Strengthen the House ###
diplomacy_oath_2_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/bp2_playdate.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = diplomacy_oath_2
		has_variable = diplomacy_oath_2_timer
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		save_temporary_scope_as = root_temp_scope
		custom_tooltip = {
			text = custom_children_oath_decision_trigger
			any_child = {
				count >= 7
				NOT = { has_trait = bastard }
			}
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = diplomacy_oath_2 }

		every_child = {
			custom = custom_children_renown_effect
			limit = {

			}
			dynasty = { add_dynasty_prestige = 30 }
		}

		show_as_tooltip = {
			add_character_modifier = oath_of_children
		}

		hidden_effect = {
			remove_variable = diplomacy_oath_2_timer
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Martial
### Consolidate the [GetPlayer.MakeScope.Var('oath_reconquest_title').Title.GetTierAsNameNoTooltip] ###
martial_oath_1_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp2_decision_struggle_hostility.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = martial_oath_1
		has_variable = martial_oath_1_timer
		var:oath_reconquest_title ?= { is_titular = no }
	}

	is_valid = {
		completely_controls = var:oath_reconquest_title
	}

	is_valid_showing_failures_only = {
		var:oath_reconquest_title.holder ?= root
	}

	effect = {
		coronation_oath_success_effect = { OATH = martial_oath_1 }

		show_as_tooltip = {
			add_character_modifier = oath_of_reconquest
		}

		var:oath_reconquest_title = {
			every_de_jure_county = {
				custom = oath_reconquest_custom_de_jure_county
				add_county_modifier = {
					modifier = oath_of_reconquest_county
					years = 25
				}
			}
		}

		hidden_effect = {
			remove_variable = martial_oath_1_timer
		}
	}

	ai_will_do = {
		base = 100
	}
}

### Expand the Realm ###
martial_oath_2_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp2_decision_struggle_hostility.dds" }
	decision_group_type = oaths

	widget = {
		controller = create_holy_order
		barony_valid = {
			OR = {
				this = scope:ruler.capital_barony
				AND = {
					duchy = {
						title_capital_county = prev.county
					}
					is_capital_barony = yes
					this.county = {
						NOT = { target_is_de_jure_liege_or_above = scope:ruler.primary_title }
					}
					trigger_if = {
						limit = {
							scope:ruler.primary_title.tier = tier_kingdom
						}
						duchy ?= {
							any_title_to_title_neighboring_duchy = {
								target_is_de_jure_liege_or_above = scope:ruler.primary_title
							}
						}
					}
					trigger_else_if = {
						limit = {
							scope:ruler.primary_title.tier = tier_empire
						}
						kingdom ?= {
							any_title_to_title_neighboring_kingdom = {
								target_is_de_jure_liege_or_above = scope:ruler.primary_title
							}
						}
					}
					trigger_else = {
						empire ?= {
							any_title_to_title_neighboring_empire = {
								target_is_de_jure_liege_or_above = scope:ruler.primary_title
							}
						}
					}
				}
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = martial_oath_2
		has_variable = martial_oath_2_timer
		has_variable = oath_conquest_size
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		sub_realm_size >= var:oath_conquest_size
	}

	effect = {
		coronation_oath_success_effect = { OATH = martial_oath_2 }

		show_as_tooltip = {
			add_character_modifier = oath_of_conquest
		}

		if = {
			limit = {
				scope:barony = root.capital_barony
			}
			capital_county = {
				add_county_modifier = {
					modifier = oath_of_conquest_county
					years = 25
				}
			}
		}
		else_if = {
			limit = {
				highest_held_title_tier = tier_kingdom
			}
			scope:barony.duchy = {
				set_de_jure_liege_title = root.primary_title
			}
		}
		else_if = {
			limit = {
				highest_held_title_tier = tier_empire
			}
			scope:barony.kingdom = {
				set_de_jure_liege_title = root.primary_title
			}
		}
		else_if = {
			limit = {
				highest_held_title_tier = tier_hegemony
			}
			scope:barony.empire = {
				set_de_jure_liege_title = root.primary_title
			}
		}

		hidden_effect = {
			remove_variable = martial_oath_2_timer
			remove_variable = oath_conquest_size
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Stewardship
### Ensure Peace ###
stewardship_oath_1_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/decision_culture.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = stewardship_oath_1
		has_variable = stewardship_oath_1_timer
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		trigger_if = {
			limit = {
				days_of_continuous_peace < 1825
				is_ai = no
			}
			custom_tooltip = {
				text = days_at_peace_text_alt
				days_of_continuous_peace >= 1825
			}
		}
		trigger_else_if = {
			limit = {
				is_ai = yes
			}
			days_of_continuous_peace >= 1095
		}
		trigger_else = {
			custom_tooltip = {
				text = days_at_peace_text
				days_of_continuous_peace >= 1825
			}
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = stewardship_oath_1 }

		if = {
			limit = {
				is_ai = no
			}
			every_realm_county = {
				custom = custom_every_realm_county
				change_development_progress_with_overflow = 250
			}
		}

		show_as_tooltip = {
			add_character_modifier = oath_of_peace
		}

		hidden_effect = {
			remove_variable = stewardship_oath_1_timer
		}
	}

	ai_will_do = {
		base = 100
	}
}

### Shape the Realm ###
stewardship_oath_2_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/ep3_decision_city.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = stewardship_oath_2
		has_variable = stewardship_oath_2_timer
		has_variable = stewardship_oath_2_buildings
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		trigger_if = {
			limit = {
				is_ai = no
			}
			custom_tooltip = {
				text = building_oath_trigger
				var:stewardship_oath_2_buildings >= 8
			}
		}
		trigger_else = {
			limit = {
				is_ai = yes
			}
			custom_tooltip = {
				text = building_oath_trigger
				var:stewardship_oath_2_buildings >= 3
			}
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = stewardship_oath_2 }

		if = {
			limit = {
				has_variable_list = stewardship_oath_2_building_list
				is_ai = no
			}
			every_in_list = {
				custom = every_build_oath_place
				variable = stewardship_oath_2_building_list
				limit = {
				
				}
				county = {
					change_development_progress_with_overflow = 50
				}
			}
		}

		show_as_tooltip = {
			add_character_modifier = oath_of_buildings
		}

		hidden_effect = {
			remove_variable = stewardship_oath_2_timer
			remove_variable = stewardship_oath_2_buildings
			clear_variable_list = stewardship_oath_2_building_list
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Learning
### Foster Enlightenment ###
learning_oath_1_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds" }
	decision_group_type = oaths

	widget = {
		controller = create_holy_order
		barony_valid = {
			trigger_if = {
				limit = {
					scope:ruler = {
						has_variable = learning_oath_1_university_exists
						any_realm_province = { has_university_building_trigger = yes }
					}
				}
				title_province = { has_university_building_trigger = yes }
			}
			trigger_else = {
				title_province = {
					has_special_building_slot = no
					is_county_capital = yes
				}
				holder = scope:ruler
			}
		}
	}

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	cost = {
		gold = {
			value = 100
			if = {
				limit = {
					exists = var:learning_oath_cost
				}
				value = var:learning_oath_cost
			}
			if = {
				limit = {
					scope:barony.county.title_province ?= {
						has_university_building_trigger = yes
					}
				}
				divide = 4
			}
		}
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = learning_oath_1
		has_variable = learning_oath_1_timer
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		OR = {
			has_trait = education_diplomacy_5
			has_trait = education_martial_5
			has_trait = education_stewardship_5
			has_trait = education_intrigue_5
			has_trait = education_learning_5
			AND = {
				trigger_if = {
					limit = {
						has_free_council_slot = yes
					}
					has_free_council_slot = no
				}
				trigger_if = {
					limit = {
						exists = cp:councillor_kurultai_1
					}
					cp:councillor_kurultai_1 = {
						OR = {
							diplomacy >= 20
							martial >= 20
							stewardship >= 20
							learning >= 20
						}
					}
				}
				trigger_if = {
					limit = {
						exists = cp:councillor_kurultai_2
					}
					cp:councillor_kurultai_2 = {
						OR = {
							diplomacy >= 20
							martial >= 20
							stewardship >= 20
							learning >= 20
						}
					}
				}
				trigger_if = {
					limit = {
						exists = cp:councillor_kurultai_3
					}
					cp:councillor_kurultai_3 = {
						OR = {
							diplomacy >= 20
							martial >= 20
							stewardship >= 20
							learning >= 20
						}
					}
				}
				trigger_if = {
					limit = {
						exists = cp:councillor_kurultai_4
					}
					cp:councillor_kurultai_4 = {
						OR = {
							diplomacy >= 20
							martial >= 20
							stewardship >= 20
							learning >= 20
						}
					}
				}
				trigger_if = {
					limit = {
						any_diplomacy_councillor = {
							count >= 1
						}
					}
					custom_tooltip = {
						text = learning_oath_1_diplomacy_councillor
						any_diplomacy_councillor = {
							count = all
							diplomacy >= 20
						}
					}
				}
				trigger_if = {
					limit = {
						any_martial_councillor = {
							count >= 1
						}
					}
					custom_tooltip = {
						text = learning_oath_1_martial_councillor
						any_martial_councillor = {
							count = all
							martial >= 20
						}
					}
				}
				trigger_if = {
					limit = {
						any_stewardship_councillor = {
							count >= 1
						}
					}
					custom_tooltip = {
						text = learning_oath_1_stewardship_councillor
						any_stewardship_councillor = {
							count = all
							stewardship >= 20
						}
					}
				}
				trigger_if = {
					limit = {
						any_intrigue_councillor = {
							count >= 1
						}
					}
					custom_tooltip = {
						text = learning_oath_1_intrigue_councillor
						any_intrigue_councillor = {
							count = all
							intrigue >= 20
						}
					}
				}
				trigger_if = {
					limit = {
						any_learning_councillor = {
							count >= 1
						}
					}
					custom_tooltip = {
						text = learning_oath_1_learning_councillor
						any_learning_councillor = {
							count = all
							learning >= 20
						}
					}
				}
			}
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = learning_oath_1 }

		if = {
			limit = {
				scope:barony.title_province ?= {
					has_university_building_trigger = no
				}
			}
			scope:barony.title_province ?= {
				add_special_building = generic_university
			}
		}
		else = {
			scope:barony.county = {
				add_county_modifier = oath_university_county
			}
		}

		hidden_effect = {
			remove_variable = learning_oath_1_timer
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Purge Pretenders
purge_pretenders_oath_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = purge_pretenders_oath
		has_variable = purge_pretenders_oath_timer
		has_variable = purge_pretenders_target_title
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		trigger_if = {
			limit = {
				NOT = {
					has_trait = murderer
				}
			}
			NOT = {
				has_trait = murderer
			}
		}
		trigger_else = {
			has_trait = murderer
			custom_tooltip = {
				text = purge_pretenders_oath_decision_murderer_tyranny
				tyranny >= 80
			}
		}
		trigger_if = {
			limit = {
				government_has_flag = government_is_nomadic
			}
			dread >= 145
		}
		trigger_else = {
			dread >= 95
		}
		custom_tooltip = {
			text = purge_pretenders_oath_decision_claimants
			var:purge_pretenders_target_title ?= {
				any_claimant = {
					count = 0
				}
			}
		}
		trigger_if = {
			limit = {
				NOT = {
					government_has_flag = government_is_nomadic
				}
			}
			custom_tooltip = {
				text = purge_pretenders_oath_decision_children
				any_child = {
					count <= 3
					has_claim_on = root.var:purge_pretenders_target_title
				}
			}
		}
		
	}

	effect = {
		coronation_oath_success_effect = { OATH = purge_pretenders_oath }

		show_as_tooltip = {
			add_character_modifier = oath_of_purge_pretenders
		}

		if = {
			limit = {
				government_has_flag = government_is_administrative
			}
			show_as_tooltip = {
				house ?= {
					add_house_modifier = oath_of_purge_pretenders_house
				}
			}
			add_character_flag = ach_purge_oath_administrative
		}
		else_if = {
			limit = {
				government_has_flag = government_is_nomadic
			}
			custom_tooltip = {
				text = purge_pretenders_oath_nomad
			}
			add_character_flag = purge_pretenders_oath_nomad
		}
		else_if = {
			limit = {
				NOR = {
					has_realm_law = single_heir_succession_law
					has_realm_law = clan_harmonious_partition_succession_law
					has_realm_law = single_heir_succession_law_youngest
					has_realm_law = single_heir_dynasty_house
				}
			}
			
			switch = {
				trigger = has_realm_law
				confederate_partition_succession_law = {
					set_variable = {
						name = purge_oath_previous_law
						value = flag:confederate_partition_succession_law
					}
				}
				partition_succession_law = {
					set_variable = {
						name = purge_oath_previous_law
						value = flag:partition_succession_law
					}
				}
				high_partition_succession_law = {
					set_variable = {
						name = purge_oath_previous_law
						value = flag:high_partition_succession_law
					}
				}
				clan_antagonistic_partition_succession_law = {
					set_variable = {
						name = purge_oath_previous_law
						value = flag:clan_antagonistic_partition_succession_law
					}
				}
				clan_competitive_partition_succession_law = {
					set_variable = {
						name = purge_oath_previous_law
						value = flag:clan_competitive_partition_succession_law
					}
				}
				clan_impassive_partition_succession_law = {
					set_variable = {
						name = purge_oath_previous_law
						value = flag:clan_impassive_partition_succession_law
					}
				}
				clan_friendly_partition_succession_law = {
					set_variable = {
						name = purge_oath_previous_law
						value = flag:clan_friendly_partition_succession_law
					}
				}
			}
			
			add_realm_law_skip_effects = single_heir_succession_law
			custom_tooltip = purge_pretenders_oath_decision_default
		}
		else = {
			add_legitimacy = massive_legitimacy_gain
		}

		hidden_effect = {
			remove_variable = purge_pretenders_oath_timer
			remove_variable = purge_pretenders_target_title
		}
	}

	ai_will_do = {
		base = 100
	}

}


## End the Struggle
end_the_struggle_oath_decision = {
	picture = {
		trigger = { var:end_the_struggle_oath_type_var = flag:persian_struggle }
		reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds"
	}
	picture = {
		trigger = { var:end_the_struggle_oath_type_var = flag:iberian_struggle }
		reference = "gfx/interface/illustrations/decisions/fp2_decision_struggle_compromise.dds"
	}
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					var:end_the_struggle_oath_type_var = flag:persian_struggle
					exists = struggle:persian_struggle
				}
				desc = end_the_struggle_oath_decision_title_persian
			}
			triggered_desc = {
				trigger = {
					var:end_the_struggle_oath_type_var = flag:persian_struggle
				}
				desc = end_the_struggle_oath_decision_title_persian_ended
			}
			triggered_desc = {
				trigger = {
					var:end_the_struggle_oath_type_var = flag:iberian_struggle
					exists = struggle:iberian_struggle
				}
				desc = end_the_struggle_oath_decision_title_iberian
			}
			triggered_desc = {
				trigger = {
					var:end_the_struggle_oath_type_var = flag:iberian_struggle
				}
				desc = end_the_struggle_oath_decision_title_iberian_ended
			}
		}
	}

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					var:end_the_struggle_oath_type_var = flag:persian_struggle
					exists = struggle:persian_struggle
				}
				desc = end_the_struggle_oath_decision_desc_persian
			}
			triggered_desc = {
				trigger = {
					var:end_the_struggle_oath_type_var = flag:persian_struggle
				}
				desc = end_the_struggle_oath_decision_desc_persian_ended
			}
			triggered_desc = {
				trigger = {
					var:end_the_struggle_oath_type_var = flag:iberian_struggle
					exists = struggle:iberian_struggle
				}
				desc = end_the_struggle_oath_decision_desc_iberian
			}
			triggered_desc = {
				trigger = {
					var:end_the_struggle_oath_type_var = flag:iberian_struggle
				}
				desc = end_the_struggle_oath_decision_desc_iberian_ended
			}
		}
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = end_the_struggle_oath
		has_variable = end_the_struggle_oath_timer
		has_variable = end_the_struggle_oath_type_var
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		trigger_if = {
			limit = {
				var:end_the_struggle_oath_type_var = flag:persian_struggle
				exists = struggle:persian_struggle
			}
			custom_tooltip = {
				text = end_the_struggle_oath_decision_trigger_persian
				has_character_flag = ach_ended_struggle
			}
		}
		trigger_if = {
			limit = {
				var:end_the_struggle_oath_type_var = flag:persian_struggle
				NOT = { exists = struggle:persian_struggle }
			}
			custom_tooltip = {
				text = end_the_struggle_oath_decision_trigger_persian_ended
				has_character_flag = ach_ended_struggle
			}
		}
		trigger_else_if = {
			limit = {
				var:end_the_struggle_oath_type_var = flag:iberian_struggle
				exists = struggle:iberian_struggle
			}
			custom_tooltip = {
				text = end_the_struggle_oath_decision_trigger_iberian
				has_character_flag = ach_ended_struggle
			}
		}
		trigger_else_if = {
			limit = {
				var:end_the_struggle_oath_type_var = flag:iberian_struggle
				NOT = { exists = struggle:iberian_struggle }
			}
			custom_tooltip = {
				text = end_the_struggle_oath_decision_trigger_iberian_ended
				has_character_flag = ach_ended_struggle
			}
		}
		
		trigger_else = {
			always = yes
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = end_the_struggle_oath }

		show_as_tooltip = {
			add_character_modifier = oath_of_end_the_struggle
		}

		hidden_effect = {
			remove_variable = end_the_struggle_oath_timer
			remove_variable = end_the_struggle_oath_type_var
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Greatest Hunter
greatest_hunter_oath_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = greatest_hunter_oath
		has_variable = greatest_hunter_oath_l_counter
		has_variable = greatest_hunter_oath_r_counter
		has_variable = greatest_hunter_oath_timer
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		OR = {
			custom_tooltip = {
				text = greatest_hunter_decision_l1_trigger
				var:greatest_hunter_oath_l_counter >= 1
			}
			custom_tooltip = {
				text = greatest_hunter_decision_r10_trigger
				var:greatest_hunter_oath_r_counter >= 10
			}
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = greatest_hunter_oath }

		show_as_tooltip = {
			add_character_modifier = oath_greatest_hunter
		}

		if = {
			limit = {
				any_character_artifact = {
					OR = {
						artifact_type = longbow
						artifact_type = composite
						artifact_type = bow
					}
				}
			}
			random_character_artifact = {
				limit = {
					OR = {
						artifact_type = longbow
						artifact_type = composite
						artifact_type = bow
					}
					is_equipped = yes
				}
				alternative_limit = {
					OR = {
						artifact_type = longbow
						artifact_type = composite
						artifact_type = bow
					}
				}
				hidden_effect = {
					add_artifact_modifier = artifact_trait_track_hunter_xp_gain_mult_4_modifier
					add_artifact_modifier = artifact_stress_gain_6_modifier
					add_artifact_modifier = artifact_tribal_opinion_1_modifier
				}
			}
		}
		custom_tooltip = greatest_hunter_decision_no_artifact_xp_effect
		custom_tooltip = greatest_hunter_decision_no_artifact_stress_effect
		custom_tooltip = greatest_hunter_decision_no_artifact_tribal_effect

		hidden_effect = {
			remove_variable = greatest_hunter_oath_timer
			remove_variable = greatest_hunter_oath_l_counter
			remove_variable = greatest_hunter_oath_r_counter
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Heir Preparation
heir_preparation_oath_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = heir_preparation_oath
		has_variable = heir_preparation_oath_timer
		exists = root.house
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		primary_heir ?= {
			house ?= root.house
			age >= 12
			calc_true_if = {
				amount >= 3
				AND = {
					diplomacy >= 10
					stewardship >= 10
					martial >= 10
					intrigue >= 10
					learning >= 10
				}
				diplomacy >= 14
				stewardship >= 14
				martial >= 14
				intrigue >= 14
				learning >= 14
				has_trait = intellect_good
				has_trait = beauty_good
				has_trait = physique_good
			}
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = heir_preparation_oath }

		show_as_tooltip = {
			add_character_modifier = oath_heir_preparation

			primary_heir ?= {
				add_character_modifier = oath_heir_preparation_heir
			}
		}

		hidden_effect = {
			remove_variable = heir_preparation_oath_timer
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Install Claimants
install_claimants_oath_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = install_claimants_oath
		has_variable = install_claimants_oath_timer
		has_variable = install_claimants_oath_counter
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		custom_tooltip = {
			text = install_claimants_oath_decision_trigger
			var:install_claimants_oath_counter >= 3
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = install_claimants_oath }

		show_as_tooltip = {
			add_character_modifier = oath_install_claimants
		}

		every_ruler = {
			limit = {
				root = {
					is_target_in_variable_list = {
						name = installed_claimants_oath
						target = prev
					}
				}
			}
			if = {
				limit = {
					root = {
						can_add_hook = {
							type = oath_claimant
							target = prev
						}
					}
				}
				root = {
					add_hook = {
						type = oath_claimant
						target = prev
					}
				}
			}
			primary_heir ?= {
				if = {
					limit = {
						exists = this
						house ?= prev.house
						root = {
							can_add_hook = {
								type = oath_claimant_heir
								target = prev
							}
						}
					}
					root = {
						add_hook = {
							type = oath_claimant_heir
							target = prev
						}
					}
				}
			}
		}
		hidden_effect = {
			remove_variable = install_claimants_oath_timer
			remove_variable = install_claimants_oath_counter
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Mend the Fracture
mend_the_fracture_oath_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = mend_the_fracture_oath
		has_variable = mend_the_fracture_oath_timer
		has_variable = mend_the_fracture_oath_target_culture
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		var:mend_the_fracture_oath_target_culture = {
			cultural_acceptance = {
				target = root.culture
				value >= 70
			}
		}
		var:mend_the_fracture_oath_target_culture = {
			any_culture_county = {
				count >= 12
				holder.top_liege = root.top_liege
			}
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = mend_the_fracture_oath }

		show_as_tooltip = {
			add_character_modifier = oath_mend_the_fracture

			culture = {
				add_culture_tradition = oath_mend_the_fracture_tradition
			}
			var:mend_the_fracture_oath_target_culture = {
				add_culture_tradition = oath_mend_the_fracture_tradition
			}
		}

		hidden_effect = {
			remove_variable = mend_the_fracture_oath_timer
			remove_variable = mend_the_fracture_oath_target_culture
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Provide for the Warriors
provide_for_the_warriors_oath_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = provide_for_the_warriors_oath
		has_variable = provide_for_the_warriors_oath_timer
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		any_directly_owned_province = {
			count >= 3
			has_building_or_higher = oath_warriors_building_02
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = provide_for_the_warriors_oath }

		show_as_tooltip = {
			add_character_modifier = oath_provide_for_the_warriors
		}
		every_directly_owned_province = {
			limit = {
				has_building_or_higher = oath_warriors_building_02
			}
			add_province_modifier = oath_provide_for_the_warriors_province
		}

		hidden_effect = {
			remove_variable = provide_for_the_warriors_oath_timer
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Provide for the Faithful
provide_for_the_faithful_oath_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = provide_for_the_faithful_oath
		has_variable = provide_for_the_faithful_oath_timer
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		any_directly_owned_province = {
			count >= 3
			has_building_or_higher = oath_faithful_building_02
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = provide_for_the_faithful_oath }

		show_as_tooltip = {
			add_character_modifier = oath_provide_for_the_faithful
		}
		every_directly_owned_province = {
			limit = {
				has_building_or_higher = oath_faithful_building_02
			}
			add_province_modifier = oath_provide_for_the_faithful_province
		}

		hidden_effect = {
			remove_variable = provide_for_the_faithful_oath_timer
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Provide for the Poor
provide_for_the_poor_oath_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = provide_for_the_poor_oath
		has_variable = provide_for_the_poor_oath_timer
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		any_directly_owned_province = {
			count >= 3
			has_building_or_higher = oath_poor_building_02
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = provide_for_the_poor_oath }

		show_as_tooltip = {
			add_character_modifier = oath_provide_for_the_poor
		}

		every_directly_owned_province = {
			limit = {
				has_building_or_higher = oath_poor_building_02
			}
			add_province_modifier = oath_provide_for_the_poor_province
		}

		hidden_effect = {
			remove_variable = provide_for_the_poor_oath_timer
		}
	}

	ai_will_do = {
		base = 100
	}
}

## Repent
repent_oath_decision = {
	picture = { reference = "gfx/interface/illustrations/decisions/fp3/fp3_decision_foundation.dds" }
	decision_group_type = oaths

	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		highest_held_title_tier >= tier_kingdom
		has_variable = repent_oath
		has_variable = repent_oath_timer
	}

	is_valid_showing_failures_only = {
		custom_tooltip = {
			text = busy_in_coronation_tooltip
			NOT = {
				involved_activity ?= {
					activity_host = root
					has_activity_type = activity_coronation
				}
			}
		}
	}

	is_valid = {
		calc_true_if = {
			amount >= 1
			num_sinful_traits = 0
			AND = {
				custom_tooltip = {
					text = repent_oath_pilgrimage
					var:repent_oath_pilgrimage_counter >= 4
				}
				piety_level >= 3
				trigger_if = {
					limit = {
						exists = faith.religious_head
						root != faith.religious_head
					}
					faith.religious_head = {
						opinion = {
							target = root
							value >= 50
						}
					}
				}
			}
		}
	}

	effect = {
		coronation_oath_success_effect = { OATH = repent_oath }

		show_as_tooltip = {
			add_character_modifier = oath_repent
		}

		every_trait_in_category = {
			category = personality
			if = {
				limit = {
					root.faith = {
						trait_is_virtue = prev
					}
				}
				add_to_list = number_of_viable_personality_virtue_traits
			}
		}

		every_character_trait = {
			if = {
				limit = {
					root.faith = {
						trait_is_sin = prev
					}
				}
				if = {
					limit = {
						has_trait_category = personality
					}
					add_to_list = personality_traits_to_remove
				}
				if = {
					limit = {
						OR = {
							has_trait_category = lifestyle
							has_trait_category = fame
						}					
					}
					add_to_list = lifestyle_and_fame_traits_to_remove
				}
			}
		}
		custom_tooltip = repent_oath_remove_traits_tooltip
		hidden_effect = {
			every_in_list = {
				list = lifestyle_and_fame_traits_to_remove
				save_temporary_scope_as = lifestyle_and_fame_temp_trait
				root = {
					remove_trait = scope:lifestyle_and_fame_temp_trait
				}
			}
			every_in_list = {
				list = personality_traits_to_remove
				if = {
					limit = {
						any_in_list = {
							list = number_of_viable_personality_virtue_traits
							root = {
								NOT = {
									has_trait = prev
								}
							}
						}
					}
					save_temporary_scope_as = personality_temp_trait
					root = {
						remove_trait = scope:personality_temp_trait
					}
					random_trait = {
						limit = {
							root.faith = {
								trait_is_virtue = prev
							}
							NOT = {
								root = {
									has_trait = prev
								}
							}
							has_trait_category = personality
						}
						save_temporary_scope_as = temp_trait
					}
					root = {
						add_trait = scope:temp_trait
					}
				}
			}
		}

		hidden_effect = {
			remove_variable = repent_oath_timer
		}
	}

	ai_will_do = {
		base = 100
	}
}
