# Supported types:
# character, spouse, rivals, friends, liege_titles, vassal_titles, realm_titles, realm_characters, realm_characters_plus, independent_rulers

###############
# AMBITIONS
###############

# Job Ambitions

obj_become_chancellor = {
	type = character

	expectation_of_liege = yes
	
	potential = {
		independent = no
		NOT = { has_character_modifier = planning_claimant_adventure }
		liege = {
			is_playable = yes
			religion_group = ROOT
			num_of_baron_titles = 1
			NOT = { is_married = ROOT }
		}
	}

	allow = {
		diplomacy = 8
		is_voter = no
		can_be_chancellor_trigger = yes
	}
	chance = {
		factor = 10
		modifier = {
			factor = 0
			NOR = {
				NOT = { has_dlc = "Zeus" }
				trait = ambitious
				powerful_vassal_wants_council_trigger = yes
				relative_income_to_liege = 0.5
				NOT = { liege = { job_chancellor = { always = yes } } }
				liege = { job_chancellor = { attribute_diff = { attribute = diplomacy character = ROOT value = 3 } } }
			}
		}
		modifier = {
			factor = 0
			liege = {
				primary_title = { has_law = council_privileges_1 }
				job_chancellor = { always = yes }
			}
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.1
			trait = shy
		}
		modifier = {
			factor = 0.25
			trait = slothful
		}
		modifier = {
			factor = 1.25
			from_ruler_dynasty = yes
		}
		modifier = {
			factor = 1.5
			trait = poet
		}
		modifier = {
			factor = 1.5
			trait = falconer
		}
		modifier = {
			factor = 1.5
			trait = gregarious
		}
		modifier = {
			factor = 2.0
			trait = ambitious
		}
		modifier = {
			factor = 10.0
			OR = {
				trait = grey_eminence
				trait = socializer
			}
		}
		modifier = {
			factor = 0.5
			NOR = {
				trait = naive_appeaser
				trait = underhanded_rogue
				trait = charismatic_negotiator
				trait = grey_eminence
			}
		}
		modifier = {
			factor = 1.25
			diplomacy = 12
		}
		modifier = {
			factor = 1.25
			diplomacy = 14
		}
		modifier = {
			factor = 1.25
			diplomacy = 16
		}
		modifier = {
			factor = 1.5
			diplomacy = 18
		}
		modifier = {
			factor = 1.5
			diplomacy = 20
		}
		modifier = {
			factor = 20
			liege = { job_chancellor = { NOT = { diplomacy = ROOT } } }
		}
		modifier = { 
			factor = 10
			has_dlc = "Zeus"
			is_ruler = yes
			relative_power_to_liege = 0.25
			powerful_vassal_wants_council_trigger = yes
		}
		modifier = { 
			factor = 5
			has_dlc = "Zeus"
			is_ruler = yes
			relative_income_to_liege = 0.5
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		has_job_title = job_chancellor
	}
	abort = {
		OR = {
			independent = yes
			AND = {
				is_voter = yes
				NOT = { has_job_title = job_chancellor }
			}
			liege = { is_married = ROOT }
			NOT = { liege = { religion_group = ROOT } }
			can_be_chancellor_trigger = no
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			change_variable = { which = "lifestyle_diplomacy" value = 1 }
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = {
				NOT = { has_character_flag = obj_become_councillor }
			}
			change_diplomacy = 1
		}
		liege = {
			reverse_opinion = {
				who = ROOT
				modifier = opinion_ambition_fulfilled
				months = 120
			}
		}
		set_character_flag = obj_become_councillor
	}
	is_job_ambition = yes
}

obj_become_marshal = {
	type = character
	
	expectation_of_liege = yes
	
	potential = {
		independent = no
		NOT = { has_character_modifier = planning_claimant_adventure }
		liege = {
			religion_group = ROOT
			is_playable = yes
			num_of_baron_titles = 1
			NOT = { is_married = ROOT }
		}
	}

	allow = {
		is_voter = no
		can_be_marshal_trigger = yes
		martial = 8
	}
	chance = {
		factor = 10
		modifier = {
			factor = 0
			NOR = {
				NOT = { has_dlc = "Zeus" }
				trait = ambitious
				powerful_vassal_wants_council_trigger = yes
				relative_income_to_liege = 0.5
				NOT = { liege = { job_marshal = { always = yes } } }
				liege = { job_marshal = { attribute_diff = { attribute = martial character = ROOT value = 3 } } }
			}
		}
		modifier = {
			factor = 0
			liege = {
				primary_title = { has_law = council_privileges_1 }
				job_marshal = { always = yes }
			}
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.1
			trait = craven
		}
		modifier = {
			factor = 0.25
			trait = slothful
		}
		modifier = {
			factor = 1.25
			from_ruler_dynasty = yes
		}
		modifier = {
			factor = 1.5
			trait = duelist
		}
		modifier = {
			factor = 1.5
			trait = hunter
		}
		modifier = {
			factor = 1.5
			trait = brave
		}
		modifier = {
			factor = 2.0
			trait = ambitious
		}
		modifier = {
			factor = 10.0
			OR = {
				trait = brilliant_strategist
				trait = strategist
			}
		}
		modifier = {
			factor = 0.5
			NOR = {
				trait = misguided_warrior
				trait = tough_soldier
				trait = skilled_tactician
				trait = brilliant_strategist
			}
		}
		modifier = {
			factor = 1.25
			martial = 12
		}
		modifier = {
			factor = 1.25
			martial = 14
		}
		modifier = {
			factor = 1.25
			martial = 16
		}
		modifier = {
			factor = 1.5
			martial = 18
		}
		modifier = {
			factor = 1.5
			martial = 20
		}
		modifier = {
			factor = 10
			liege = { job_marshal = { NOT = { martial = ROOT } } }
		}
		modifier = { 
			factor = 10
			has_dlc = "Zeus"
			is_ruler = yes
			relative_power_to_liege = 0.25
			powerful_vassal_wants_council_trigger = yes
		}
		modifier = { 
			factor = 5
			has_dlc = "Zeus"
			is_ruler = yes
			relative_income_to_liege = 0.5
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		has_job_title = job_marshal
	}
	abort = {
		OR = {
			independent = yes
			AND = {
				is_voter = yes
				NOT = { has_job_title = job_marshal }
			}
			liege = { is_married = ROOT }
			NOT = { liege = { religion_group = ROOT } }
			can_be_marshal_trigger = no
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			change_variable = { which = "lifestyle_martial" value = 1 }
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = {
				NOT = { has_character_flag = obj_become_councillor }
			}
			change_martial = 1
		}
		liege = {
			reverse_opinion = {
				who = ROOT
				modifier = opinion_ambition_fulfilled
				months = 120
			}
		}
		set_character_flag = obj_become_councillor
	}
	is_job_ambition = yes
}

obj_become_treasurer = {
	type = character
	
	expectation_of_liege = yes
	
	potential = {
		independent = no
		NOT = { has_character_modifier = planning_claimant_adventure }
		liege = {
			religion_group = ROOT
			is_playable = yes
			num_of_baron_titles = 1
			NOT = { is_married = ROOT }
		}
	}

	allow = {
		is_voter = no
		can_be_treasurer_trigger = yes
		stewardship = 8
	}
	chance = {
		factor = 10
		modifier = {
			factor = 0
			NOR = {
				NOT = { has_dlc = "Zeus" }
				trait = ambitious
				powerful_vassal_wants_council_trigger = yes
				relative_income_to_liege = 0.5
				NOT = { liege = { job_treasurer = { always = yes } } }
				liege = { job_treasurer = { attribute_diff = { attribute = stewardship character = ROOT value = 3 } } }
			}
		}
		modifier = {
			factor = 0
			liege = {
				primary_title = { has_law = council_privileges_1 }
				job_treasurer = { always = yes }
			}
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.1
			trait = charitable
		}
		modifier = {
			factor = 0.25
			trait = slothful
		}
		modifier = {
			factor = 1.25
			from_ruler_dynasty = yes
		}
		modifier = {
			factor = 1.5
			trait = scholar
		}
		modifier = {
			factor = 1.5
			trait = gardener
		}
		modifier = {
			factor = 1.5
			trait = gluttonous
		}
		modifier = {
			factor = 1.5
			trait = temperate
		}
		modifier = {
			factor = 1.5
			trait = greedy
		}
		modifier = {
			factor = 2.0
			trait = ambitious
		}
		modifier = {
			factor = 10.0
			OR = {
				trait = midas_touched
				trait = administrator
			}
		}
		modifier = {
			factor = 0.5
			NOR = {
				trait = indulgent_wastrel
				trait = thrifty_clerk
				trait = fortune_builder
				trait = midas_touched
			}
		}
		modifier = {
			factor = 1.25
			stewardship = 12
		}
		modifier = {
			factor = 1.25
			stewardship = 14
		}
		modifier = {
			factor = 1.25
			stewardship = 16
		}
		modifier = {
			factor = 1.5
			stewardship = 18
		}
		modifier = {
			factor = 1.5
			stewardship = 20
		}
		modifier = {
			factor = 10
			liege = { job_treasurer = { NOT = { stewardship = ROOT } } }
		}
		modifier = { 
			factor = 10
			has_dlc = "Zeus"
			is_ruler = yes
			relative_power_to_liege = 0.25
			powerful_vassal_wants_council_trigger = yes
		}
		modifier = { 
			factor = 5
			has_dlc = "Zeus"
			is_ruler = yes
			relative_income_to_liege = 0.5
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		has_job_title = job_treasurer
	}
	abort = {
		OR = {
			independent = yes
			AND = {
				is_voter = yes
				NOT = { has_job_title = job_treasurer }
			}
			liege = { is_married = ROOT }
			NOT = { liege = { religion_group = ROOT } }
			can_be_treasurer_trigger = no
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			change_variable = { which = "lifestyle_stewardship" value = 1 }
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = {
				NOT = { has_character_flag = obj_become_councillor }
			}
			change_stewardship = 1
		}
		liege = {
			reverse_opinion = {
				who = ROOT
				modifier = opinion_ambition_fulfilled
				months = 120
			}
		}
		set_character_flag = obj_become_councillor
	}
	is_job_ambition = yes
}

obj_become_spymaster = {
	type = character
	
	expectation_of_liege = yes
	
	potential = {
		independent = no
		NOT = { has_character_modifier = planning_claimant_adventure }
		liege = {
			religion_group = ROOT
			is_playable = yes
			num_of_baron_titles = 1
			NOT = { is_married = ROOT }
		}
	}
	
	allow = {
		is_voter = no
		can_be_spymaster_trigger = yes
		intrigue = 8
	}
	chance = {
		factor = 10
		modifier = {
			factor = 0
			NOR = {
				NOT = { has_dlc = "Zeus" }
				trait = ambitious
				powerful_vassal_wants_council_trigger = yes
				relative_income_to_liege = 0.5
				NOT = { liege = { job_spymaster = { always = yes } } }
				liege = { job_spymaster = { attribute_diff = { attribute = intrigue character = ROOT value = 3 } } }
			}
		}
		modifier = {
			factor = 0
			liege = {
				primary_title = { has_law = council_privileges_1 }
				job_spymaster = { always = yes }
			}
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.1
			trait = kind
		}
		modifier = {
			factor = 0.1
			trait = honest
		}
		modifier = {
			factor = 0.25
			trait = slothful
		}
		modifier = {
			factor = 1.25
			from_ruler_dynasty = yes
		}
		modifier = {
			factor = 1.5
			trait = envious
		}
		modifier = {
			factor = 1.5
			trait = mystic
		}
		modifier = {
			factor = 1.5
			trait = impaler
		}
		modifier = {
			factor = 2.0
			trait = deceitful
		}
		modifier = {
			factor = 2.0
			trait = ambitious
		}
		modifier = {
			factor = 10.0
			OR = {
				trait = elusive_shadow
				trait = schemer
			}
		}
		modifier = {
			factor = 1.25
			intrigue = 12
		}
		modifier = {
			factor = 1.25
			intrigue = 14
		}
		modifier = {
			factor = 1.25
			intrigue = 16
		}
		modifier = {
			factor = 1.5
			intrigue = 18
		}
		modifier = {
			factor = 1.5
			intrigue = 20
		}
		modifier = {
			factor = 10
			liege = { job_spymaster = { NOT = { intrigue = ROOT } } }
		}
		modifier = { 
			factor = 10
			has_dlc = "Zeus"
			is_ruler = yes
			relative_power_to_liege = 0.25
			powerful_vassal_wants_council_trigger = yes
		}
		modifier = { 
			factor = 5
			has_dlc = "Zeus"
			is_ruler = yes
			relative_income_to_liege = 0.5
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		has_job_title = job_spymaster
	}
	abort = {
		OR = {
			independent = yes
			AND = {
				is_voter = yes
				NOT = { has_job_title = job_spymaster }
			}
			liege = { is_married = ROOT }
			NOT = { liege = { religion_group = ROOT } }
			can_be_spymaster_trigger = no
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			change_variable = { which = "lifestyle_intrigue" value = 1 }
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = {
				NOT = { has_character_flag = obj_become_councillor }
			}
			change_intrigue = 1
		}
		liege = {
			reverse_opinion = {
				who = ROOT
				modifier = opinion_ambition_fulfilled
				months = 120
			}
		}
		set_character_flag = obj_become_councillor
	}
	is_job_ambition = yes
}

obj_become_spiritual = {
	type = character
	
	expectation_of_liege = yes
	
	potential = {
		independent = no
		NOT = { has_character_modifier = planning_claimant_adventure }
		NOT = { liege = { is_married = ROOT } }
		liege = {
			religion = ROOT
			is_playable = yes
			num_of_baron_titles = 1
			NOT = { is_married = ROOT }
		}
	}

	allow = {
		is_voter = no
		can_be_spiritual_trigger = yes
		learning = 8
	}
	chance = {
		factor = 10
		modifier = {
			factor = 0
			NOR = {
				NOT = { has_dlc = "Zeus" }
				trait = ambitious
				powerful_vassal_wants_council_trigger = yes
				relative_income_to_liege = 0.5
				NOT = { liege = { job_spiritual = { always = yes } } }
				liege = { job_spiritual = { attribute_diff = { attribute = learning character = ROOT value = 3 } } }
			}
		}
		modifier = {
			factor = 0
			liege = {
				primary_title = { has_law = council_privileges_1 }
				job_spiritual = { always = yes }
			}
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.1
			trait = cynical
		}
		modifier = {
			factor = 0.25
			trait = slothful
		}
		modifier = {
			factor = 1.25
			from_ruler_dynasty = yes
		}
		modifier = {
			factor = 1.5
			trait = zealous
		}
		modifier = {
			factor = 2.0
			trait = ambitious
		}
		modifier = {
			factor = 10.0
			OR = {
				is_theocracy = yes
				trait = theologian
			}
		}
		modifier = {
			factor = 0.5
			NOR = {
				trait = detached_priest
				trait = martial_cleric
				trait = scholarly_theologian
				trait = mastermind_theologian
			}
		}
		modifier = {
			factor = 1.25
			learning = 12
		}
		modifier = {
			factor = 1.25
			learning = 14
		}
		modifier = {
			factor = 1.25
			learning = 16
		}
		modifier = {
			factor = 1.5
			learning = 18
		}
		modifier = {
			factor = 1.5
			learning = 20
		}
		modifier = {
			factor = 10
			liege = { job_spiritual = { NOT = { learning = ROOT } } }
		}
		modifier = { 
			factor = 10
			has_dlc = "Zeus"
			is_ruler = yes
			relative_power_to_liege = 0.25
			powerful_vassal_wants_council_trigger = yes
		}
		modifier = { 
			factor = 5
			has_dlc = "Zeus"
			is_ruler = yes
			relative_income_to_liege = 0.5
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		has_job_title = job_spiritual
	}
	abort = {
		OR = {
			independent = yes
			AND = {
				is_voter = yes
				NOT = { has_job_title = job_spiritual }
			}
			liege = { is_married = ROOT }
			can_be_spiritual_trigger = no
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			change_variable = { which = "lifestyle_learning" value = 1 }
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = {
				NOT = { has_character_flag = obj_become_councillor }
			}
			change_learning = 1
		}
		liege = {
			reverse_opinion = {
				who = ROOT
				modifier = opinion_ambition_fulfilled
				months = 120
			}
		}
		set_character_flag = obj_become_councillor
	}
	is_job_ambition = yes
}

# Misc Ambitions

obj_amass_wealth = {
	type = character
	
	potential = {
		NOT = { has_character_flag = obj_amass_wealth }
		lower_tier_than = DUKE
		NOT = { num_of_count_titles = 4 }
	}
	
	allow = {
		is_adult = yes
		NOT = { wealth = 250 }
		is_ruler = yes
		NOT = { trait = charitable }
		NOT = { trait = incapable }
		NOT = { has_character_modifier = loan_timer }
		NOT = { has_character_flag = loan_taken }
	}
	chance = {
		factor = 100

		modifier = {
			factor = 1.25
			trait = patient
		}
		modifier = {
			factor = 1.25
			trait = fortune_builder
		}
		modifier = {
			factor = 1.25
			trait = midas_touched
		}
		modifier = {
			factor = 10.0
			trait = greedy
		}
		modifier = {
			factor = 0
			trait = charitable
		}
		modifier = {
			factor = 0
			trait = content
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		wealth = 250
		NOT = { has_character_modifier = loan_timer }
		NOT = { has_character_flag = loan_taken }
	}
	abort = {
		OR = {
			trait = incapable
			trait = charitable
			has_character_modifier = loan_timer
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		change_stewardship = 1
		set_character_flag = obj_amass_wealth
		if = {
			limit = { any_vassal = { leads_faction = faction_prosperity } }
			custom_tooltip = { text = PROSPERITYFACTIONMOODPLUS }
			hidden_tooltip = {
				change_variable = { which = "lifestyle_stewardship" value = 1 }
				random_vassal = { limit = { leads_faction = faction_prosperity } set_variable = { which = "faction_mood_increase" value = 2 } }
				character_event = { id = PlusFaction.200 days = 1 } #recalculate faction moods
			}
		}
	}
}

obj_become_paragon_of_virtue = {
	type = character
	
	potential = {
		NOT = { religion_group = indian_group }
		NOT = { trait = paragon }
	}

	allow = {
		is_adult = yes
		piety = 500
		NOT = { piety = 1000 }
		is_ruler = yes
		NOT = { trait = cruel }
		NOT = { trait = impaler }
		NOT = { trait = incapable }
		NOT = { trait = decadent }
	}
	chance = {
		factor = 50

		modifier = {
			factor = 1.25
			trait = patient
		}
		modifier = {
			factor = 0.01
			NOT = { tier = king }
			NOT = { tier = emperor }
		}
		modifier = {
			factor = 0
			NOT = { piety = 250 }
		}
		modifier = {
			factor = 10.0
			OR = {
				trait = detached_priest
				trait = martial_cleric
				trait = scholarly_theologian
				trait = mastermind_theologian
			}
		}
		modifier = {
			factor = 10.0
			trait = zealous
		}
		modifier = {
			factor = 0
			trait = cynical
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		piety = 1000
	}
	abort = {
		OR = {
			is_ruler = no
			NOT = { piety = 0 }
			trait = incapable
			trait = cruel
			trait = impaler
			trait = paragon
			trait = decadent
			religion_group = indian_group
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		change_learning = 1
		piety = 100
		if = {
			limit = { any_vassal = { leads_faction = faction_tradition } }
			custom_tooltip = { text = TRADITIONFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_tradition } set_variable = { which = "faction_mood_increase" value = 4 } }
				character_event = { id = PlusFaction.200 days = 1 } #recalculate faction moods
			}
		}
		if = {
			limit = { has_nickname = no }
			give_nickname = nick_the_holy
		}
		religion_authority = {
			modifier = paragon_of_virtue
			years = 20
		}
		add_trait = paragon
	}
}

obj_become_exalted = {
	type = character
	
	potential = {
		is_ruler = yes
		NOR = { 
			trait = exalted1
			trait = exalted2
			trait = exalted3
			trait = exalted4
		}
		lower_tier_than = DUKE
		NOT = { num_of_count_titles = 4 }
	}

	allow = {
		is_adult = yes
		prestige = 0
		NOT = { prestige = 1000 }
		NOT = { trait = content }
		NOT = { trait = humble }
		NOT = { trait = incapable }
	}
	chance = {
		factor = 50

		modifier = {
			factor = 1.25
			trait = patient
		}
		modifier = {
			factor = 0
			NOT = { prestige = 250 }
		}
		modifier = {
			factor = 5.0
			trait = ambitious
		}
		modifier = {
			factor = 10.0
			trait = proud
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		prestige = 1000
	}
	abort = {
		OR = {
			is_ruler = no
			NOT = { prestige = 0 }
			trait = incapable
			trait = content
			trait = humble
			trait = exalted1
			trait = exalted2
			trait = exalted3
			trait = exalted4
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		change_diplomacy = 1
		prestige = 100
		if = {
			limit = { any_vassal = { leads_faction = faction_court } }
			custom_tooltip = { text = COURTFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_court } set_variable = { which = "faction_mood_increase" value = 2 } }
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_glory } }
			custom_tooltip = { text = GLORYFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_glory } set_variable = { which = "faction_mood_increase" value = 4 } }
			}
		}
		hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } #recalculate faction moods
		add_trait = exalted1
	}
}

obj_get_married = {
	type = character
	
	potential = {
		NOT = { has_landed_title = k_papal_state }
		is_married = no
		is_consort = no
		can_marry = yes
	}

	allow = {
		prisoner = no
		is_adult = yes
		NOT = { trait = celibate }
		NOT = { trait = eunuch }
		NOT = { trait = incapable }
		NOT = { is_ascetic_trigger = yes }
		OR = {
			is_female = no
			NOT = { age = 40 }
		}
		OR = {
			is_ruler = no
			is_feudal = yes
			is_tribal = yes
			is_nomadic = yes
			is_patrician = yes
		}
		OR = {
			ai = no
			NOT = { has_character_flag = obj_get_married }
		}
	}
	chance = {
		factor = 100
		modifier = {
			factor = 0.1
			trait = homosexual
		}
		modifier = {
			factor = 0.1
			trait = chaste
		}
		modifier = {
			factor = 0.5
			trait = shy
		}
		modifier = {
			factor = 2.0
			trait = lustful
		}
		modifier = {
			factor = 2.0
			trait = ambitious
		}
		modifier = {
			factor = 2.0
			age = 25
		}
		modifier = {
			factor = 5.0
			age = 35
		}
		modifier = {
			factor = 10.0
			age = 40
		}
		modifier = {
			factor = 0.01
			mercenary = yes
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		is_married = yes
	}
	abort = {
		OR = {
			prisoner = yes
			AND = {
				can_marry = no
				is_married = no
			}
			AND = {
				is_female = yes
				is_ruler = no
				age = 40
			}
			is_consort = yes
			trait = celibate
			trait = eunuch
			trait = incapable
			is_ascetic_trigger = yes
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = flag_promised_marriage
		clr_character_flag = flag_denied_marriage
		hidden_tooltip = {
			remove_character_modifier = promised_a_marriage
		}
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_court } }
			custom_tooltip = { text = COURTFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_court } set_variable = { which = "faction_mood_increase" value = 1 } }
				character_event = { id = PlusFaction.200 days = 1 } #recalculate faction moods
			}
		}
		if = {
			limit = { NOT = { has_character_flag = obj_get_married } }
			piety = 25
		}
		if = {
			limit = { has_character_flag = obj_get_married }
			piety = 10
		}
		if = {
			limit = { is_ruler = no }
			liege = {
				reverse_opinion = {
					who = ROOT
					modifier = opinion_fulfilled_marriage_wish
					months = 24
				}
			}
		}
		clr_character_flag = flag_promised_marriage
		clr_character_flag = flag_denied_marriage
		hidden_tooltip = {
			remove_character_modifier = promised_a_marriage
		}
		set_character_flag = obj_get_married
	}
}

obj_marry_ruler = {
	type = character

	potential = {
		is_married = no
		is_consort = no
		can_marry = yes
		is_female = yes
	}

	allow = {
		prisoner = no
		is_adult = yes
		is_ruler = no
		NOT = { trait = celibate }
		NOT = { trait = incapable }
		NOT = { age = 45 }
		father = {
			primary_title = {
				higher_tier_than = COUNT
			}
		}
		OR = {
			ai = no
			NOT = { has_character_flag = obj_get_married }
		}
	}
	chance = {
		factor = 100		
		modifier = {
			factor = 0.1
			trait = chaste
		}
		modifier = {
			factor = 1.5
			trait = midas_touched
		}
		modifier = {
			factor = 1.5
			trait = elusive_shadow
		}
		modifier = {
			factor = 2.0
			trait = greedy
		}
		modifier = {
			factor = 5.0
			trait = ambitious
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		is_married = yes
		spouse = { is_ruler = yes }
	}
	abort = {
		OR = {
			is_ruler = yes
			AND = {
				can_marry = no
				is_married = no
			}
			is_consort = yes
			prisoner = yes
			age = 45
			trait = celibate
			trait = incapable
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = { NOT = { has_character_flag = obj_get_married } }
			prestige = 50
		}
		if = {
			limit = { has_character_flag = obj_get_married }
			prestige = 25
		}
		set_character_flag = obj_get_married
	}
}

obj_have_a_daughter = {
	type = character

	fertility = 0.1
	
	potential = {
		is_adult = yes
		OR = {
			is_married = yes
			is_consort = yes
		}
		NOT = {
			any_child = {
				is_female = yes
			}
		}
		OR = {
			ai = no
			is_female = yes
			num_of_children = 2
		}
	}

	allow = {
		prisoner = no
		OR = {
			NOT = { age = 45 }
			is_female = no
		}
		NOT = { age = 75 }
		NOT = { trait = celibate }
		NOT = { trait = eunuch }
		NOT = { trait = incapable }
		OR = {
			ai = no
			NOT = { has_character_flag = obj_have_child_1 }
		}
	}
	chance = {
		factor = 50

		modifier = {
			factor = 0.1
			is_female = no
			NOT = {
				any_child = {
					is_female = no
				}
			}
		}
		modifier = {
			factor = 2.0
			is_female = yes
		}
		modifier = {
			factor = 5.0
			is_ruler = yes
			higher_tier_than = BARON
			OR = {
				is_vice_royalty = yes
				has_law = succ_gavelkind
				has_law = succ_primogeniture
				has_law = succ_feudal_elective
				has_law = succ_turkish_succession
				has_law = succ_nomad_succession
			}
			OR = {
				has_law = enatic_cognatic_succession
				has_law = enatic_succession
			}
			NOT = {
				any_child = {
					dynasty = ROOT
					can_inherit_trigger = yes
					NOR = {
						trait = incapable
						trait = celibate
					}
					OR = {
						AND = {
							ROOT = {
								OR = {
									has_law = succ_gavelkind
									has_law = succ_primogeniture
									has_law = succ_turkish_succession
									has_law = succ_nomad_succession
								}
							}
							is_primary_heir = ROOT
						}
						AND = {
							ROOT = {
								OR = {
									is_vice_royalty = yes
									has_law = succ_feudal_elective
								}							
							}
							any_heir_title = {
								tier = COUNT
								holder = ROOT
								location = { is_capital = yes }
							}
						}
					}
				}
			}
		}
		modifier = {
			factor = 1.5
			num_of_children = 3
		}
		modifier = {
			factor = 3.0
			num_of_children = 4
		}
		modifier = {
			factor = 10.0
			num_of_children = 5
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		any_child = {
			is_female = yes
		}
	}
	abort = {
		OR = {
			prisoner = yes
			AND = {
				age = 45
				is_female = yes
			}
			AND = {
				age = 75
				is_female = no
			}
			AND = {
				is_married = no
				is_consort = no
			}
			trait = celibate
			trait = eunuch
			trait = incapable
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_court } }
			custom_tooltip = { text = COURTFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_court } set_variable = { which = "faction_mood_increase" value = 1 } }
				character_event = { id = PlusFaction.200 days = 1 } #recalculate faction moods
			}
		}
		if = {
			limit = { NOT = { has_character_flag = obj_have_child_1 } }
			piety = 25
		}
		if = {
			limit = { has_character_flag = obj_have_child_1 }
			piety = 10
		}
		set_character_flag = obj_have_child_1
	}
}

obj_have_a_son = {
	type = character

	fertility = 0.1
	
	potential = {
		is_adult = yes
		OR = {
			is_married = yes
			is_consort = yes
		}
		NOT = {
			any_child = {
				is_female = no
			}
		}
	}

	allow = {
		prisoner = no
		OR = {
			NOT = { age = 45 }
			is_female = no
		}
		NOT = { age = 75 }
		NOT = { trait = celibate }
		NOT = { trait = eunuch }
		NOT = { trait = incapable }
		OR = {
			ai = no
			NOT = { has_character_flag = obj_have_child_2 }
		}
	}
	chance = {
		factor = 50

		modifier = {
			factor = 0.5
			is_female = yes
		}
		modifier = {
			factor = 5.0
			is_ruler = yes
			higher_tier_than = BARON
			OR = {
				is_vice_royalty = yes
				has_law = succ_gavelkind
				has_law = succ_primogeniture
				has_law = succ_feudal_elective
				has_law = succ_turkish_succession
				has_law = succ_nomad_succession
			}
			NOR = {
				has_law = enatic_cognatic_succession
				has_law = enatic_succession
			}
			NOT = {
				any_child = {
					dynasty = ROOT
					can_inherit_trigger = yes
					NOR = {
						trait = incapable
						trait = celibate
					}
					OR = {
						AND = {
							ROOT = {
								OR = {
									has_law = succ_gavelkind
									has_law = succ_primogeniture
									has_law = succ_turkish_succession
									has_law = succ_nomad_succession
								}
							}
							is_primary_heir = ROOT
						}
						AND = {
							ROOT = {
								OR = {
									is_vice_royalty = yes
									has_law = succ_feudal_elective
								}							
							}
							any_heir_title = {
								tier = COUNT
								holder = ROOT
								location = { is_capital = yes }
							}
						}
					}
				}
			}
		}
		modifier = {
			factor = 5
			is_ruler = yes
			OR = {
				religion_group = muslim
				is_nomadic = yes
			}
		}
		modifier = {
			factor = 10
			has_focus = focus_family
		}
		modifier = {
			factor = 5
			age = 30
		}
		modifier = {
			factor = 5
			age = 45
		}
		modifier = {
			factor = 2
			trait = genius
		}
		modifier = {
			factor = 2
			trait = quick
		}
		modifier = {
			factor = 1.5
			num_of_children = 3
		}
		modifier = {
			factor = 3.0
			num_of_children = 4
		}
		modifier = {
			factor = 10.0
			num_of_children = 5
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		any_child = {
			is_female = no
		}
	}
	abort = {
		OR = {
			prisoner = yes
			trait = celibate
			trait = eunuch
			trait = incapable
			AND = {
				age = 45
				is_female = yes
			}
			AND = {
				age = 75
				is_female = no
			}
			AND = {
				is_married = no
				is_consort = no
			}
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_court } }
			custom_tooltip = { text = COURTFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_court } set_variable = { which = "faction_mood_increase" value = 1 } }
				character_event = { id = PlusFaction.200 days = 1 } #recalculate faction moods
			}
		}
		if = {
			limit = { NOT = { has_character_flag = obj_have_child_2 } }
			prestige = 50
		}
		if = {
			limit = { has_character_flag = obj_have_child_2 }
			prestige = 25
		}
		set_character_flag = obj_have_child_2
	}
}

obj_wants_landed_title = {
	type = character
	
	potential = {
		is_ruler = no
	}

	allow = {
		prisoner = no
		is_adult = yes
		OR = {
			is_female = no
			liege = {
				OR = {
					has_law = true_cognatic_succession
					has_law = enatic_cognatic_succession
					has_law = enatic_succession
				}
			}
		}
		NOT = { is_ascetic_trigger = yes }
		NOT = { trait = incapable }
		NOT = { trait = eunuch }
		NOT = { has_minor_title = title_guru }
		liege = {
			OR = {
				is_feudal = yes
				is_tribal = yes
			}
			is_close_relative = ROOT
			num_of_extra_landed_titles = 1
			NOT = { any_spouse = { character = ROOT } }
		}
		NOT = { has_character_flag = obj_landed_title }
	}
	chance = {
		factor = 200

		modifier = {
			factor = 0.1
			liege = {
				primary_title = {
					has_law = succ_gavelkind
				}
			}
		}
		modifier = {
			factor = 0.5
			NOT = {
				liege = {
					any_child = {
						character = ROOT
					}
				}
			}
		}
		modifier = {
			factor = 10
			has_character_modifier = planning_claimant_adventure
		}
		modifier = {
			factor = 0.85
			has_character_modifier = estates_1
		}
		modifier = {
			factor = 0.70
			has_character_modifier = estates_2
		}
		modifier = {
			factor = 0.55
			has_character_modifier = estates_3
		}
		modifier = {
			factor = 0.40
			has_character_modifier = estates_4
		}
		modifier = {
			factor = 0.25
			has_character_modifier = estates_5
		}
		modifier = {
			factor = 0.5
			is_primary_heir = no
		}
		modifier = {
			factor = 0.1
			NOR = {
				any_sibling = {
					is_liege_of = ROOT
				}
				father = {
					is_liege_of = ROOT
				}
				mother = {
					is_liege_of = ROOT
				}
			}
		}
		modifier = {
			factor = 0
			trait = content
		}
		modifier = {
			factor = 0.25
			trait = patient
		}
		modifier = {
			factor = 0.5
			trait = humble
		}
		modifier = {
			factor = 1.25
			trait = proud
		}
		modifier = {
			factor = 1.5
			trait = greedy
		}
		modifier = {
			factor = 2.0
			trait = envious
		}
		modifier = {
			factor = 3.0
			trait = ambitious
		}
		modifier = {
			factor = 5.0
			trait = decadent
		}
		modifier = {
			factor = 2.0
			religion_group = muslim
			liege = { dynasty = ROOT }
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		is_ruler = yes
	}
	abort = {
		OR = {
			prisoner = yes
			trait = incapable
			trait = eunuch
			is_ascetic_trigger = yes
			has_minor_title = title_guru
			liege = {
				OR = {
					AND = {
						is_feudal = no
						is_tribal = no
					}
					any_spouse = { character = ROOT }
					NOT = { is_close_relative = ROOT }
					NOT = { num_of_extra_landed_titles = 1 }
				}
			}
			AND = {
				is_female = yes
				liege = {
					NOT = { has_law = true_cognatic_succession }
					NOT = { has_law = enatic_cognatic_succession }
					NOT = { has_law = enatic_succession }
				}
			}
			has_opinion_modifier = { who = liege modifier = opinion_denied_title }
			has_opinion_modifier = { who = liege modifier = opinion_broken_title_promise }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = flag_denied_title
		clr_character_flag = flag_promised_title
		remove_character_modifier = promised_a_title
		clr_character_flag = flag_later_title
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		prestige = 100
		liege = {
			reverse_opinion = {
				who = ROOT
				modifier = opinion_generous_relative
				months = 120
			}
		}
		hidden_tooltip = {
			clr_character_flag = flag_denied_title
			clr_character_flag = flag_promised_title
			remove_character_modifier = promised_a_title
			clr_character_flag = flag_later_title
			liege = { reverse_remove_opinion = { who = ROOT modifier = opinion_promised_title } }
		}
		set_character_flag = obj_landed_title
	}
}

obj_become_heir = {
	type = character
	
	potential = {
		NOT = { has_character_flag = obj_become_heir }
		liege = { any_child = { character = ROOT } }
		NAND = { 
			liege = { primary_title = { has_law = agnatic_succession } }
			is_female = yes
		}
		NOT = { trait = bastard }
		liege = {
			any_child = {
				is_primary_heir = yes
				OR = {
					has_epidemic = yes
					is_ill = yes
					trait = lunatic
					trait = possessed
					trait = incapable
					trait = infirm
				}
			}
		}
	}

	allow = {
		prisoner = no
		is_adult = yes
		is_primary_heir = no
		NOT = { trait = incapable }
	}
	chance = {
		factor = 50

		modifier = {
			factor = 4.0
			trait = ambitious
		}
		modifier = {
			factor = 1.5
			trait = greedy
		}
		modifier = {
			factor = 1.5
			trait = envious
		}
		modifier = {
			factor = 1.5
			trait = proud
		}
		modifier = {
			factor = 0.5
			trait = patient
		}
		modifier = {
			factor = 0
			trait = content
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		is_primary_heir = yes
	}
	abort = {
		OR = {
			prisoner = yes
			NOT = { liege = { any_child = { character = ROOT } } }
			trait = incapable
			independent = yes
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		change_intrigue = 1
		set_character_flag = obj_become_heir
	}
}

### Ambitions to improve abilitites

# Martial
obj_improve_martial = {
	type = character

	potential = {
		is_adult = yes
		is_ruler = yes
		prisoner = no
		NOT = { has_dlc = "Way of Life" }
	}

	allow = {
		NOT = { martial = 8 }
		NOT = { trait = infirm }
		NOT = { trait = incapable }
	}
	chance = {
		factor = 20

		modifier = {
			factor = 1.25
			trait = diligent
		}
		modifier = {
			factor = 1.25
			trait = misguided_warrior
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		martial = 8
	}
	abort = {
		OR = {
			trait = incapable
			trait = infirm
			prisoner = yes
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = improve_martial_success
		clr_character_flag = toy_army_prepare
		clr_character_flag = toy_army
		clr_character_flag = street_ruffians
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = {
				NOT = { has_character_flag = obj_improve_attribute }
			}
			prestige = 100
			set_character_flag = obj_improve_attribute
		}
		if = {
			limit = {
				has_character_flag = obj_improve_attribute
			}
			prestige = 25
		}
		clr_character_flag = improve_martial_success
		clr_character_flag = toy_army_prepare
		clr_character_flag = toy_army
		clr_character_flag = street_ruffians
	}
}

# Stewardship
obj_improve_stewardship = {
	type = character

	potential = {
		is_adult = yes
		is_ruler = yes
		prisoner = no
		NOT = { has_dlc = "Way of Life" }		
	}

	allow = {
		NOT = { stewardship = 8 }
		NOT = { trait = infirm }
		NOT = { trait = incapable }
	}
	chance = {
		factor = 20

		modifier = {
			factor = 1.25
			trait = diligent
		}
		modifier = {
			factor = 1.25
			trait = indulgent_wastrel
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		stewardship = 8
	}
	abort = {
		OR = {
			trait = incapable
			trait = infirm
			prisoner = yes
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = 10_salt
		clr_character_flag = 20_salt
		clr_character_flag = 30_salt
		clr_character_flag = all_salt
		clr_character_flag = the_inn
		clr_character_flag = the_garden
		clr_character_flag = the_survey
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = {
				has_character_flag = obj_improve_attribute
			}
			prestige = 25
		}
		if = {
			limit = {
				NOT = { has_character_flag = obj_improve_attribute }
			}
			prestige = 100
			set_character_flag = obj_improve_attribute
		}
		clr_character_flag = improve_stewardship_success
		clr_character_flag = the_inn
		clr_character_flag = the_garden
		clr_character_flag = the_survey
	}
}

# Learning
obj_improve_learning = {
	type = character

	potential = {
		is_adult = yes
		is_ruler = yes
		prisoner = no
		NOT = { has_dlc = "Way of Life" }		
	}

	allow = {
		NOT = { learning = 8 }
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 20

		modifier = {
			factor = 1.25
			trait = diligent
		}
		modifier = {
			factor = 1.25
			trait = detached_priest
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		learning = 8
	}
	abort = {
		OR = {
			trait = incapable
			trait = infirm
			prisoner = yes
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = flying_machine
		clr_character_flag = ancient_tome
		clr_character_flag = hermit_visit
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = {
				has_character_flag = obj_improve_attribute
			}
			prestige = 25
		}
		if = {
			limit = {
				NOT = { has_character_flag = obj_improve_attribute }
			}
			prestige = 100
			set_character_flag = obj_improve_attribute
		}
		clr_character_flag = improve_learning_success
		clr_character_flag = flying_machine
		clr_character_flag = ancient_tome
		clr_character_flag = hermit_visit
	}
}

# Diplomacy
obj_improve_diplomacy = {
	type = character

	potential = {
		is_adult = yes
		is_ruler = yes
		prisoner = no
		NOT = { has_dlc = "Way of Life" }
	}

	allow = {
		NOT = { diplomacy = 8 }
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 20

		modifier = {
			factor = 1.25
			trait = diligent
		}
		modifier = {
			factor = 1.25
			trait = naive_appeaser
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		diplomacy = 8
	}
	abort = {
		OR = {
			trait = incapable
			trait = infirm
			prisoner = yes
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = the_feud
		clr_character_flag = the_mirror
		clr_character_flag = the_suicide
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = {
				has_character_flag = obj_improve_attribute
			}
			prestige = 25
		}
		if = {
			limit = {
				NOT = { has_character_flag = obj_improve_attribute }
			}
			prestige = 100
			set_character_flag = obj_improve_attribute
		}
		clr_character_flag = improve_diplomacy_success
		clr_character_flag = the_feud
		clr_character_flag = the_mirror
		clr_character_flag = the_suicide
	}
}

# Intrigue
obj_improve_intrigue = {
	type = character

	potential = {
		is_adult = yes
		is_ruler = yes
		prisoner = no
		NOT = { has_dlc = "Way of Life" }
	}

	allow = {
		NOT = { intrigue = 8 }
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 20

		modifier = {
			factor = 1.25
			trait = diligent
		}
		modifier = {
			factor = 1.25
			trait = naive_appeaser
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		intrigue = 8
	}
	abort = {
		OR = {
			trait = incapable
			trait = infirm
			prisoner = yes
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = the_necklace
		clr_character_flag = gossip
		clr_character_flag = old_spymaster
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		if = {
			limit = {
				has_character_flag = obj_improve_attribute
			}
			prestige = 25
		}
		if = {
			limit = {
				NOT = { has_character_flag = obj_improve_attribute }
			}
			prestige = 100
			set_character_flag = obj_improve_attribute
		}
		clr_character_flag = improve_intrigue_success
		clr_character_flag = the_necklace
		clr_character_flag = gossip
		clr_character_flag = old_spymaster
	}
}

# Decadence
obj_lower_decadence60 = {
	type = character

	potential = {
		is_adult = yes
		is_ruler = yes
		uses_decadence = yes
	}
	allow = {
		religion_group = muslim
		NOT = {decadence = 65}
		decadence = 60
		NOT = { trait = incapable }
		NOT = { has_character_modifier = lower_decadence_obj_timer }
	}
	chance = {
		factor = 100

		modifier = {
			factor = 1.25
			trait = diligent
		}
		modifier = {
			factor = 1.25
			trait = naive_appeaser
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		NOT = {decadence = 50}
	}
	abort = {
		OR = {
			trait = incapable
			is_ruler = no
			NOT = { religion_group = muslim }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = berber_life
		clr_character_flag = bandit_camp
		clr_character_flag = dromedary_hunt
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		prestige = 100
		hidden_tooltip = {
			add_character_modifier = {
				name = lower_decadence_obj_timer
				duration = 1825 #5 years
			}
		}
		clr_character_flag = lower_decadence_success
		clr_character_flag = berber_life
		clr_character_flag = bandit_camp
		clr_character_flag = dromedary_hunt
	}
}

# Become King
obj_become_king = {
	type = character

	can_cancel = no

	ai_capital_kingdom_focus = yes # AI characters with this ambition will actually focus on taking the kingdom

	potential = {
		is_adult = yes
		is_playable = yes
		is_landed = yes
		lower_tier_than = KING
		OR = {
			independent = yes
			liege = { independent = yes }
		}
		OR = {
			primary_title = { is_primary_type_title = no }
			ai = no
		}
		NOT = {
			any_heir_title = {
				higher_tier_than = DUKE
			}
		}
	}

	allow = {
		NOT = { trait = incapable }
	}

	chance = {
		factor = 100

		modifier = {
			factor = 0.05
			NOT = { trait = ambitious }
		}
		modifier = {
			factor = 3.0
			capital_scope = {
				kingdom = {
					has_holder = no
				}
			}
		}
		modifier = {
			factor = 0.3
			capital_scope = {
				kingdom = {
					holder_scope = {  ROOT = { liege = { character = PREVPREV } } }
				}
			}
		}
		modifier = {
			factor = 3.0
			trait = ambitious
		}
		modifier = {
			factor = 2.0
			trait = brave
		}
		modifier = {
			factor = 3.0
			OR = {
				independent = yes
				AND = {
					is_pagan_religion = yes
					is_reformed_pagan_religion = no
				}
			}
		}
		modifier = {
			factor = 3.0
			num_of_duke_titles = 2
		}
		modifier = {
			factor = 0.1
			trait = craven
		}
		modifier = {
			factor = 0.01
			trait = content
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
		modifier = {
			factor = 0.1
			tier = COUNT
		}
		modifier = {
			factor = 0.01
			OR = {
				religion = finnish_pagan
				religion = west_african_pagan
			}
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		custom_tooltip = {
			text = obj_become_king_tip
			hidden_tooltip = {
				OR = {
					capital_scope = {
						kingdom = {
							holder_scope = { character = ROOT }
						}
					}
					AND = {
						higher_tier_than = DUKE
						primary_title = { temporary = no }
					}
				}
			}
		}
	}

	abort = {
		OR = {
			trait = incapable
			is_playable = no
			is_landed = no
			AND = {
				independent = no
				liege = { independent = no }
			}
			any_heir_title = {
				higher_tier_than = DUKE
				temporary = no
			}
			AND = {
				ai = yes
				primary_title = { is_primary_type_title = yes }
			}
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}

	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}

	effect = {
		hidden_tooltip = {
			clr_character_flag = kingdom_claimed_with_ambition
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		prestige = 250
	}
}

### Buddhist ambitions ###

obj_buddhist_stop_drinking = {
	type = character
	
	potential = {
		religion = buddhist
		trait = drunkard
	}
	
	allow = {
		is_adult = yes
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 100
		
		modifier = {
			factor = 2
			trait = zealous
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		NOT = { trait = drunkard }
	}
	abort = {
		OR = {
			NOT = { religion = buddhist }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = guru_helped_ambition
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		piety = 100
		clr_character_flag = guru_helped_ambition
	}
}

obj_buddhist_reject_empty_pleasures = {
	type = character
	
	potential = {
		religion = buddhist
		trait = hedonist
	}
	
	allow = {
		is_adult = yes
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 100
		
		modifier = {
			factor = 2
			trait = zealous
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		NOT = { trait = hedonist }
	}
	abort = {
		OR = {
			NOT = { religion = buddhist }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = guru_helped_ambition
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		piety = 100
		clr_character_flag = guru_helped_ambition
	}
}

obj_buddhist_abstain_sexual_excess = {
	type = character
	
	potential = {
		religion = buddhist
		trait = lustful
	}
	
	allow = {
		is_adult = yes
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 100
		
		modifier = {
			factor = 2
			trait = zealous
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		NOT = { trait = lustful }
	}
	abort = {
		OR = {
			NOT = { religion = buddhist }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = guru_helped_ambition
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		piety = 100
		clr_character_flag = guru_helped_ambition
	}
}

obj_buddhist_reject_cruelty = {
	type = character
	
	potential = {
		religion = buddhist
		OR = {
			trait = impaler
			trait = cruel
		}
	}
	
	allow = {
		is_adult = yes
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 100
		
		modifier = {
			factor = 2
			trait = zealous
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		NOT = { trait = impaler }
		NOT = { trait = cruel }
	}
	abort = {
		OR = {
			NOT = { religion = buddhist }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = guru_helped_ambition
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		piety = 100
		clr_character_flag = guru_helped_ambition
	}
}

obj_buddhist_temperance_food = {
	type = character
	
	potential = {
		religion = buddhist
		trait = gluttonous
	}
	
	allow = {
		is_adult = yes
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 100
		
		modifier = {
			factor = 2
			trait = zealous
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		NOT = { trait = gluttonous }
	}
	abort = {
		OR = {
			NOT = { religion = buddhist }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = guru_helped_ambition
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		piety = 100
		clr_character_flag = guru_helped_ambition
	}
}

obj_buddhist_reject_greed = {
	type = character
	
	potential = {
		religion = buddhist
		trait = greedy
	}
	
	allow = {
		is_adult = yes
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 100
		
		modifier = {
			factor = 2
			trait = zealous
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		NOT = { trait = greedy }
	}
	abort = {
		OR = {
			NOT = { religion = buddhist }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = guru_helped_ambition
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		piety = 100
		clr_character_flag = guru_helped_ambition
	}
}

obj_buddhist_reject_envy = {
	type = character
	
	potential = {
		religion = buddhist
		trait = envious
	}
	
	allow = {
		is_adult = yes
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 100
		
		modifier = {
			factor = 2
			trait = zealous
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		NOT = { trait = envious }
	}
	abort = {
		OR = {
			NOT = { religion = buddhist }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = guru_helped_ambition
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		piety = 100
		clr_character_flag = guru_helped_ambition
	}
}

obj_buddhist_reject_hate = {
	type = character
	
	potential = {
		religion = buddhist
		trait = wroth
	}
	
	allow = {
		is_adult = yes
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 100
		
		modifier = {
			factor = 2
			trait = zealous
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		NOT = { trait = wroth }
	}
	abort = {
		OR = {
			NOT = { religion = buddhist }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = guru_helped_ambition
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		piety = 100
		clr_character_flag = guru_helped_ambition
	}
}

obj_buddhist_reject_pride = {
	type = character
	
	potential = {
		religion = buddhist
		trait = proud
	}
	
	allow = {
		is_adult = yes
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 100
		
		modifier = {
			factor = 2
			trait = zealous
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		NOT = { trait = proud }
	}
	abort = {
		OR = {
			NOT = { religion = buddhist }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = guru_helped_ambition
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		piety = 100
		clr_character_flag = guru_helped_ambition
	}
}

obj_buddhist_defeat_fear = {
	type = character
	
	potential = {
		religion = buddhist
		OR = {
			trait = paranoid
			trait = craven
		}
	}
	
	allow = {
		is_adult = yes
		NOT = { trait = incapable }
		NOT = { trait = infirm }
	}
	chance = {
		factor = 100
		
		modifier = {
			factor = 2
			trait = zealous
		}
		modifier = {
			factor = 1.5
			trait = ambitious
		}
		modifier = {
			factor = 0.01
			trait = slothful
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		NOT = { trait = paranoid }
		NOT = { trait = craven }
	}
	abort = {
		OR = {
			NOT = { religion = buddhist }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
		clr_character_flag = guru_helped_ambition
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		piety = 100
		clr_character_flag = guru_helped_ambition
	}
}

obj_become_paragon_of_enlightenment = {
	type = character
	
	potential = {
		religion_group = indian_group
		is_ruler = yes
	}
	
	allow = {
		is_adult = yes
		NOT = { piety = 100 }
		is_dumb_trigger = no
		NOT = { trait = inbred }
		NOT = { trait = lunatic }
		NOT = { trait = incapable }
	}
	chance = {
		factor = 50
		
		modifier = {
			factor = 1.25
			trait = patient
		}
		modifier = {
			factor = 0.01
			NOT = { tier = king }
			NOT = { tier = emperor }
		}
		modifier = {
			factor = 10.0
			OR = {
				trait = detached_priest
				trait = martial_cleric
				trait = scholarly_theologian
				trait = mastermind_theologian
			}
		}
		modifier = {
			factor = 10.0
			trait = zealous
		}
		modifier = {
			factor = 0.01
			trait = cynical
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		piety = 500
	}
	abort = {
		OR = {
			trait = incapable
			trait = lunatic
			is_ruler = no
			NOT = { religion_group = indian_group }
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		if = {
			limit = { ai = yes }
			remove_character_modifier = ai_objective_timer
		}
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
		change_learning = 1
		piety = 100
		if = {
			limit = {
				has_nickname = no
			}
			give_nickname = nick_the_wise
		}
		religion_authority = {
			modifier = paragon_of_enlightenment
			years = 20
		}
		any_vassal = {
			limit = {
				is_theocracy = yes
				religion = ROOT
			}
			opinion = {
				who = ROOT
				modifier = opinion_enlightened
				months = 1200
			}
		}
	}
}

# See the realm prosper
obj_see_the_realm_prosper = {
	type = character
	
	creation_effect = {
		add_character_modifier = {
			name = prosperity_5_year
			years = 5
		}
	}
	
	aggression = 0.25
	
	global_revolt_risk = -0.01
	
	potential = {
		has_dlc = "Reapers"
		is_playable = yes
		is_landed = yes
		higher_tier_than = BARON
		is_nomadic = no
		liege = { is_nomadic = no }
		NOT = { has_character_modifier = prosper_ambition_timer }
	}
	
	allow = {
		any_realm_province = {
			any_province_holding = {
				OR = {
					holding_type = city
					holding_type = castle
					holding_type = tribal
				}
			}
			NOR = {
				has_province_modifier = depopulated_1
				has_province_modifier = depopulated_2
				has_province_modifier = depopulated_3
			}
		}
		war = no
		independent = yes
		is_adult = yes
		NOR = { 
			trait = incapable
			is_inaccessible_trigger = yes
		}
	}
	
	chance = {
		factor = 100
		
		modifier = {
			factor = 0.1
			OR = {
				trait = wroth
				trait = cruel
				trait = impaler
				trait = arbitrary
				trait = slothful
			}
		}
		modifier = {
			factor = 0.2
			NOR = {
				trait = architect
				trait = administrator
				trait = gardener
				trait = charitable
				trait = diligent
				trait = patient
				trait = content
				trait = just
				has_focus = focus_rulership
			}
		}
		modifier = {
			factor = 1.5
			trait = charitable
		}
		modifier = {
			factor = 1.5
			has_focus = focus_rulership
		}
		modifier = {
			factor = 3.0
			OR = {
				trait = indulgent_wastrel
				trait = thrifty_clerk
				trait = fortune_builder
				trait = midas_touched
			}
		}
	}
	
	success = {
		custom_tooltip = {
			text = tooltip_obj_see_the_realm_prosper
			hidden_tooltip = {
				NOT = {
					has_character_modifier = prosperity_5_year
				}
			}
		}
	}
	
	abort = {
		OR = {
			trait = incapable
			is_playable = no
			is_landed = no
			any_war = {
				NOR = {
					using_cb = peasant_revolt
					using_cb = heretic_revolt
					using_cb = religious_revolt
					using_cb = liberation_revolt
				}
			}
		}
	}
	
	abort_effect = {
		remove_character_modifier = prosperity_5_year
		add_character_modifier = {
		   modifier = prosper_ambition_timer
		   years = 5
		   hidden = yes
		}
	}
	
	effect = {
		change_stewardship = 1
		if = {
			limit = {
				infamy = 50
				has_game_rule = {
					name = defensive_pacts
					value = on
				}
			}
			random_list = {
				1 = { change_infamy = { value = -20 localisation = PEACEFULL_RULERSHIP } }
				5 = { change_infamy = { value = -15 localisation = PEACEFULL_RULERSHIP } }
				9 = { change_infamy = { value = -10 localisation = PEACEFULL_RULERSHIP } }
			}
			
		}
		if = {
			limit = {
				infamy = 10
				NOT = { infamy = 50 }
				has_game_rule = {
					name = defensive_pacts
					value = on
				}
			}
			random_list = {
				1 = { change_infamy = { value = -10 localisation = PEACEFULL_RULERSHIP } }
				5 = { change_infamy = { value = -5 localisation = PEACEFULL_RULERSHIP } }
			}
		}
		if = {
			limit = {
				infamy = 2
				NOT = { infamy = 10 }
				has_game_rule = {
					name = defensive_pacts
					value = on
				}
			}
			change_infamy = { value = -2 localisation = PEACEFULL_RULERSHIP }
		}
		if = {
			limit = {
				NOT = { infamy = 2 }
				has_game_rule = {
					name = defensive_pacts
					value = on
				}
			}
			prestige = 250
		}
		custom_tooltip = {
			text = realm_prospers_custom_tooltip
			hidden_tooltip = {
				any_realm_province = {
					limit = {
						any_province_holding = {
							OR = {
								holding_type = city
								holding_type = castle
								holding_type = tribal
							}
						}
						NOR = {
							has_province_modifier = depopulated_1
							has_province_modifier = depopulated_2
							has_province_modifier = depopulated_3
						}
					}
					change_variable = { which = prosperity_value value = 35 }
				}
				if = {
					limit = {
						has_nickname = no
						is_adult = yes
						NOT = { trait = incapable }
					}
					random_list = {
						5 = {
							give_nickname = nick_the_gentle
						}
						5 = {
							give_nickname = nick_the_affable
						}
						5 = {
							give_nickname = nick_the_shrewd
						}
						5 = {
							give_nickname = nick_the_gracious
						}
						100 = {}
					}
				}
			}
		}
		add_character_modifier = {
		   modifier = prosper_ambition_timer
		   years = 25
		   hidden = yes
		}
	}
}
