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

###############
# NEW AMBITIONS
###############

# Gain land for son

obj_land_for_son = {
	type = character
	
	potential = {
		always = no
		independent = no
		higher_tier_than = BARON
	}

	allow = {
		liege = {
			independent = yes
			higher_tier_than = COUNT
		}
		has_dlc = "Zeus"
		prisoner = no
		is_adult = yes
		NOR = { 
			trait = incapable 
			has_character_flag = land_for_son_successful
		}
		any_child = {
			is_alive = yes
			is_female = no
			is_landed = no
			is_adult = yes
			prisoner = no
			NOR = {
				any_heir_title = { always = yes }
				trait = bastard
				trait = disinherited
				trait = incapable
				is_ascetic_trigger = yes
				trait = desert_father
				trait = eunuch
				age = 50
			}
			liege = {
				character = ROOT
			}
		}
	}
	
	chance = {
		factor = 100
		
		modifier = {
			factor = 0.5
			trait = content
		}
		modifier = {
			factor = 3.0
			trait = ambitious
		}
		modifier = {
			factor = 0.5
			trait = shy
		}
		modifier = {
			factor = 1.5
			trait = gregarious
		}
		modifier = {
			factor = 2
			trait = proud
		}
		modifier = {
			factor = 0.5
			trait = humble
		}
		modifier = {
			factor = 1.25
			from_ruler_dynasty = yes
		}
		modifier = {
			factor = 1.5
			diplomacy = 16
		}
		modifier = { 
			factor = 10
			is_councillor = yes
		}
		modifier = { 
			factor = 5
			relative_income_to_liege = 0.5
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		custom_tooltip = {
			text = obj_land_for_son_success_tooltip
			hidden_tooltip = {
				has_character_flag = land_for_son_successful
			}
		}
	}
	abort = {
		OR = {
			NOT = {
				any_child = {
					is_alive = yes
					is_female = no
					is_landed = no
					is_adult = yes
					prisoner = no
					NOR = {
						any_heir_title = { always = yes }
						trait = bastard
						trait = disinherited
						trait = incapable
						is_ascetic_trigger = yes
						trait = desert_father
						trait = eunuch
						age = 50
					}
					liege = {
						character = ROOT
					}
				}
			}
			liege = { independent = no }
			liege = { lower_tier_than = DUKE }
			prisoner = yes
			independent = yes
			lower_tier_than = COUNT
			trait = incapable
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
	}
	effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
	}
}

obj_build_a_war_chest = {
	type = character
	
	potential = {
		has_dlc = "Zeus"
		NOT = { has_character_modifier = war_chest_timer }
		is_nomadic = no
		higher_tier_than = BARON
		is_landed = yes
	}
	
	allow = {
		is_adult = yes
		is_ruler = yes
		prisoner = no
		war = no
		OR = {
			AND = {
				tier = count
				NOT = { wealth = 300 }
			}
			AND = {
				tier = duke
				NOT = { wealth = 500 }
			}
			AND = {
				tier = king
				NOT = { wealth = 700 }
			}
			AND = {
				tier = emperor
				NOT = { wealth = 1000 }
			}
		}
		NOR = { 
			trait = incapable
			is_inaccessible_trigger = yes
		}
		
	}
	chance = {
		factor = 100
		
		modifier = {
			factor = 10
			NOT = { wealth = 0 }
		}
		modifier = {
			factor = 2
			trait = greedy
		}
		modifier = {
			factor = 2
			trait = diligent
		}
		modifier = {
			factor = 2
			martial = 10
		}
		modifier = {
			factor = 0.5
			NOT = { martial = 10 }
		}
		modifier = {
			factor = 0.5
			independent = no
		}
		modifier = {
			factor = 0.5
			trait = charitable
		}
		modifier = {
			factor = 0.5
			trait = content
		}
		modifier = {
			factor = 0.5
			trait = slothful
		}
		modifier = {
			factor = 0.5
			tier = count
			wealth = 200
		}	
		modifier = {
			factor = 0.5
			tier = duke
			wealth = 350
		}
		modifier = {
			factor = 0.5
			tier = king
			wealth = 550
		}
		modifier = {
			factor = 0.5
			tier = emperor
			wealth = 850
		}
		modifier = {
			factor = 0.5
			government = theocracy_government
		}
		modifier = {
			factor = 0.25
			tier = count
			independent = no
		}
		modifier = {
			factor = 0.5
			tier = duke
			independent = no
		}
		modifier = {
			factor = 0
			NOT = { num_of_vassals = 3 }
		}
	}
	creation_effect = {
		if = {
			limit = { ai = yes }
			add_character_modifier = {
				name = "ai_objective_timer"
				duration = 1825
				hidden = yes
			}
		}
	}
	success = {
		custom_tooltip = {
			text = obj_build_a_war_chest_success_custom_tooltip
			hidden_tooltip = {
				OR = {
					AND = {
						tier = count
						wealth = 300
					}
					AND = {
						tier = duke
						wealth = 500
					}
					AND = {
						tier = king
						wealth = 700
					}
					AND = {
						tier = emperor
						wealth = 1000
					}
				}
			}
		}
	}
	abort = {
		OR = {
			trait = incapable
			NOT = { higher_tier_than = BARON }
			is_landed = no
			prisoner = yes
			AND = {
				ai = yes
				NOT = { has_character_modifier = ai_objective_timer }
			}
		}
	}
	abort_effect = {
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
	}
	effect = {
		add_character_modifier = {
			modifier = war_taxes
			months = 60
		}
		add_character_modifier = {
		   modifier = war_chest_timer
		   years = 25
		   hidden = yes
		}
		hidden_tooltip = {
			if = {
				limit = { ai = yes }
				remove_character_modifier = ai_objective_timer
			}
		}
	}
}

obj_groom_an_heir = {
	type = character
	
	potential = {
		has_dlc = "Conclave"
		higher_tier_than = BARON
		is_adult = yes
		prisoner = no
		holy_order = no
		mercenary = no
		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
		}
	}
	
	allow = {
		has_regent = no
		NOT = { is_inaccessible_trigger = yes }
		OR = {
			NOT = { trait = eunuch }
			any_child = {
				is_alive = yes
			}
		}
		any_child = {
			NOT = { age = 12 }
			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 }
					}
				}
			}
		}
	}
	chance = {
		factor = 100
		modifier = {
			factor = 10
			has_focus = focus_family
		}
		modifier = {
			factor = 5
			trait = bastard
		}
		modifier = {
			factor = 5
			age = 30
		}
		modifier = {
			factor = 5
			age = 45
		}
		modifier = {
			factor = 5
			government = nomadic_government
		}
		modifier = {
			factor = 2
			trait = genius
		}
		modifier = {
			factor = 2
			trait = quick
		}
		modifier = {
			factor = 2
			trait = shrewd
		}
		modifier = {
			factor = 0.5
			trait = shy
		}
		modifier = {
			factor = 0.5
			trait = slothful
		}
		modifier = {
			factor = 0
			is_theocracy = yes
		}
	}
	success = {
		any_child = {
			is_adult = yes
			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 }
					}
				}
			}
		}
	}
	abort = {
		OR = {
			trait = incapable
			prisoner = yes
			NOT = { higher_tier_than = BARON }
			NOR = {
				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
			}
			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 }
							}
						}
					}
				}
			}
		}
	}
	abort_effect = {
	}
	effect = {
		custom_tooltip = {
			text = opinion_boost_child
			hidden_tooltip = {
				any_child = {
					limit = {
						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 }
								}
							}
						}
					}
					opinion = {
						who = ROOT
						modifier = opinion_family_love
						months = 240
					}
				}
			}
		}
	}
}

