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

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

# See the realm prosper
obj_see_the_realm_prosper = {
	type = character

	aggression = 0.25

	global_revolt_risk = -0.01

	potential = {
		has_dlc = "Reapers"
		is_playable = yes
		is_landed = yes
		independent = yes
		is_adult = yes
		higher_real_tier_than = BARON
		is_nomadic = no
		war = no
		is_incapable = no
		is_inaccessible_trigger = no
		NOT = { has_character_modifier = prosper_ambition_timer }

		liege = { is_nomadic = no }

		any_realm_province = {
			held_under_PREV = yes

			OR = {
				has_castle = yes
				has_tribal = yes
				has_city = yes
			}

			NOR = {
				has_province_modifier = depopulated_1
				has_province_modifier = depopulated_2
				has_province_modifier = depopulated_3
			}
		}
	}

	creation_effect = {
		add_character_modifier = {
			name = prosperity_5_year
			years = 5
		}
	}

	success = {
		custom_tooltip = {
			text = tooltip_obj_see_the_realm_prosper

			NOT = { has_character_modifier = prosperity_5_year }
		}
	}

	effect = {
		change_stewardship = 1

		custom_tooltip = {
			text = realm_prospers_custom_tooltip

			any_realm_province = {
				limit = {
					held_under_PREV = yes

					OR = {
						has_castle = yes
						has_tribal = yes
						has_city = yes
					}

					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
					is_incapable = no
				}

				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 = {
			name = prosper_ambition_timer
			years = 25
			hidden = yes
		}
	}

	abort = {
		OR = {
			is_incapable = yes
			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 = {
			name = prosper_ambition_timer
			years = 5
			hidden = yes
		}
	}

	chance = {
		factor = 100

		mult_modifier = {
			factor = 0.1

			OR = {
				trait = wroth
				trait = cruel
				trait = impaler
				trait = arbitrary
				trait = slothful
			}
		}

		mult_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
			}
		}

		mult_modifier = {
			factor = 1.5
			trait = charitable
		}

		mult_modifier = {
			factor = 1.5
			has_focus = focus_rulership
		}

		mult_modifier = {
			factor = 3.0
			has_education_stewardship_trigger = yes
		}
	}
}