###################################
#
# Zeus
# Ambition decisions
#
###################################

# Written by Markus Olsén

targeted_decisions = {

	request_council_position = {
		filter = liege
		ai_target_filter = liege
		ai_check_interval = 3

		is_high_prio = yes

		only_playable = yes

		from_potential = {
			has_dlc = "Conclave"

			OR = {
				has_ambition = obj_become_chancellor
				has_ambition = obj_become_marshal
				has_ambition = obj_become_treasurer
				has_ambition = obj_become_spymaster
				has_ambition = obj_become_spiritual
			}

			trigger_if = {
				limit = { has_character_flag = council_membership_requested }

				had_character_flag = {
					flag = council_membership_requested
					years >= 5
				}
			}
		}

		allow = {
			FROM = {
				prestige >= 100
				in_revolt = no
				is_not_in_regency_trigger = yes
				is_inaccessible_trigger = no
			}

			ROOT = {
				in_revolt = no

				NOR = {
					has_law = council_privileges_1

					has_opinion_modifier = {
						name = opinion_refused_council
						who = ROOT_FROM
					}

					has_opinion_modifier = {
						name = requested_council_position
						who = ROOT_FROM
					}
				}
			}
		}

		effect = {
			FROM = {
				show_scope_change = no

				prestige = -50
			}

			custom_tooltip = {
				text = request_council_position_tooltip

				opinion = {
					name = requested_council_position
					who = FROM
					years = 2
				}

				character_event = {
					id = ZE.6001
					days = 3
				}
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				FROM = {
					OR = {
						among_most_powerful_vassals = 5
						relative_income_to_liege = 0.5
						is_friend = liege
						holds_favor_on = liege

						trigger_if = {
							limit = { higher_real_tier_than = BARON }

							OR = {
								trait = lunatic

								AND = {
									trait = proud
									trait = ambitious
								}

								trigger_if = {
									limit = { has_ambition = obj_become_chancellor }
									liege = { job_chancellor = { is_rival = ROOT_FROM } }
								}
								trigger_else_if = {
									limit = { has_ambition = obj_become_marshal }
									liege = { job_marshal = { is_rival = ROOT_FROM } }
								}
								trigger_else_if = {
									limit = { has_ambition = obj_become_treasurer }
									liege = { job_treasurer = { is_rival = ROOT_FROM } }
								}
								trigger_else_if = {
									limit = { has_ambition = obj_become_spymaster }
									liege = { job_spymaster = { is_rival = ROOT_FROM } }
								}
								trigger_else = {
									has_ambition = obj_become_spiritual

									liege = {
										OR = {
											job_spiritual = {
												is_rival = ROOT_FROM
											}

											rightful_religious_head = ROOT_FROM
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	ask_for_land = {
		filter = liege
		ai_target_filter = liege
		ai_check_interval = 12

		is_high_prio = yes

		only_playable = yes

		from_potential = {
			OR = {
				has_ambition = obj_land_for_son
				has_ambition = obj_land_for_daughter
			}

			higher_real_tier_than = BARON
		}

		allow = {
			FROM = {
				in_revolt = no
				is_not_in_regency_trigger = yes
				is_inaccessible_trigger = no

				trigger_if = {
					limit = { has_ambition = obj_land_for_son }

					custom_tooltip = {
						text = tooltip_land_for_son

						# TODO: Should match obj_land_for_son trigger

						any_child = {
							is_female = no
							vassal_of = ROOT
							is_ruler = no
							is_adult = yes
							is_heir = no
							prisoner = no
							is_incapable = no
							has_inheritance_blocker = no
							is_ascetic_trigger = no
							practical_age < 50

							NOR = {
								trait = desert_father

								any_heir_title = {
									always = yes
								}
							}
						}
					}
				}
				trigger_else = {
					custom_tooltip = {
						text = tooltip_land_for_daugther

						# TODO: Should match obj_land_for_daughter trigger

						any_child = {
							is_female = no
							vassal_of = ROOT
							is_ruler = no
							is_adult = yes
							is_heir = no
							prisoner = no
							is_incapable = no
							has_inheritance_blocker = no
							is_ascetic_trigger = no
							practical_age < 50

							NOR = {
								trait = desert_mother

								any_heir_title = {
									always = yes
								}
							}
						}
					}
				}
			}

			ROOT = {
				in_revolt = no
				is_not_in_regency_trigger = yes
				is_inaccessible_trigger = no

				NOT = {
					has_opinion_modifier = {
						name = requested_land
						who = PREV
					}
				}

				any_demesne_title = {
					real_tier = COUNT
					can_be_given_away = yes

					location = {
						show_scope_change = no

						is_capital = no
					}
				}
			}
		}

		effect = {
			FROM = {
				show_scope_change = no

				prestige = -20
			}

			custom_tooltip = {
				text = ask_for_land_tooltip

				opinion = {
					name = requested_land
					who = FROM
					years = 2
				}

				character_event = {
					id = ZE.6012
					days = 3
				}
			}
		}

		ai_will_do = {
			factor = 0.1

			mult_modifier = {
				factor = 2
				FROM = { trait = proud }
			}

			mult_modifier = {
				factor = 2
				FROM = { trait = stubborn }
			}

			mult_modifier = {
				factor = 2
				FROM = { trait = greedy }
			}

			mult_modifier = {
				factor = 2
				FROM = { trait = ambitious}
			}

			mult_modifier = {
				factor = 0.5
				FROM = { trait = content }
			}

			mult_modifier = {
				factor = 0.5
				FROM = { trait = shy}
			}

			mult_modifier = {
				factor = 0.5
				FROM = { trait = craven}
			}

			mult_modifier = {
				factor = 0.5
				FROM = { trait = humble }
			}
		}
	}

}