#############################################
#
# Events for Family Members
#
# Event ID 37000-37999 is reserved
#
#############################################

###################################################
# Relative demands a title
###################################################

# Relative demands inheritance due to ambition
character_event = {
	id = 37000
	desc = EVTDESC37000
	picture = GFX_evt_son_asking_father
	
	min_age = 18
	capable_only = yes
	prisoner = no
	
	trigger = {
		has_ambition = obj_become_ruler
		independent = no
		liege = {
			is_close_relative = ROOT
			OR = {
				AND = {
					OR = {
						government = military_monarchy
						government = pirate_kingdom
					}
					any_demesne_title = {
						can_be_given_away = yes
						tier = count
						holding_type = castle
						location = { is_capital = no }
					}
				}
				AND = {
					government = corporate_monarchy
					any_demesne_title = {
						can_be_given_away = yes
						tier = count
						holding_type = city
						location = { is_capital = no }
					}
				}
				AND = {
					government = administrative_monarchy
					any_demesne_title = {
						can_be_given_away = yes
						tier = count
						holding_type = temple
						location = { is_capital = no }
					}
				}
			}
		}
		NOT = { has_character_flag = flag_denied_title }
		NOT = { has_character_flag = flag_promised_title }
		OR = {
			NOT = { has_character_flag = flag_later_title }
			had_character_flag = { flag = flag_later_title days = 1825 }
		}
	}
	
	mean_time_to_happen = {
		months = 12
		
		modifier = {
			factor = 0.5
			trait = ambitious
		}
		modifier = {
			factor = 0.5
			trait = disciplined
		}
		modifier = {
			factor = 5.0
			trait = carefree
		}
		modifier = {
			factor = 5.0
			trait = content
		}
	}
	
	option = {
		name = EVTOPTA37000 # Ask liege for a title
		liege = { character_event = { id = 37001 days = 3 tooltip = EVTTOOLTIP37001 } }
	}
}

# Liege responds to the request
character_event = {
	id = 37001
	desc = EVTDESC37001
	picture = GFX_evt_son_asking_father
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA37001 # Promise that you'll arrange it
		FROM = { character_event = { id = 37002 tooltip = EVTTOOLTIP37002 } }
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 100 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 90 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 80 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 70 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 60 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 50 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 40 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 30 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 20 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 10 }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -9 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -19 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -29 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -39 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -49 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -59 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -69 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -79 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -89 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -99 } }
			}
		}
	}
	
	option = {
		name = EVTOPTB37001 # Say he's not ready yet
		trigger = { NOT = { diplomacy = 8 } }
		
		FROM = { character_event = { id = 37004 tooltip = EVTTOOLTIP37004 } }
		
		if = {
			limit = {
				ai = no
				independent = yes
				FROM = {
					NOT = { trait = content }
					NOT = { trait = patient }
					NOT = { trait = craven }
					NOT = { age = 65 }
					has_character_flag = flag_later_title
				}
			}
			custom_tooltip = { text = evt_relative_might_revolt }
		}
		ai_chance = { factor = 50 }
	}
	
	option = {
		name = EVTOPTC37001 # Mention a Church career...
		tooltip_info = diplomacy
		trigger = {
			NOT = { government = administrative_monarchy }
			religion_group = religious_group
			diplomacy = 8
		}
		FROM = { character_event = { id = 37003 tooltip = EVTTOOLTIP37003 } }
		ai_chance = { factor = 50 }
	}
	
	option = {
		name = EVTOPTD37001 # Diplomatically refuse
		tooltip_info = diplomacy
		trigger = {
			OR = {
				government = administrative_monarchy
				NOT = { religion_group = religious_group }
			}
			diplomacy = 8
		}
		FROM = { character_event = { id = 37003 tooltip = EVTTOOLTIP37003 } }
		ai_chance = { factor = 50 }
	}
}

# The relative is filled with anticipation
character_event = {
	id = 37002
	desc = EVTDESC37002
	picture = GFX_evt_son_asking_father
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA37002 # It had better not be hollow words...
		opinion = {
			who = FROM
			modifier = opinion_promised_title
			months = 12
		}
		
		set_character_flag = flag_promised_title
		add_character_modifier = { name = promised_a_title duration = -1 }
		
		hidden_tooltip = {
			if = {
				limit = {
					OR = {
						trait = carefree
						trait = content
					}
					NOT = { trait = ambitious }
				}
				character_event = { id = 37005 days = 865 random = 200 }
			}
			if = {
				limit = {
					NOT = { trait = carefree }
					NOT = { trait = content }
					NOT = { trait = ambitious }
				}
				character_event = { id = 37005 days = 385 random = 200 }
			}
			if = {
				limit = { trait = ambitious }
				character_event = { id = 37005 days = 365 random = 50 }
			}
		}
	}
}

# The relative is deeply offended
character_event = {
	id = 37003
	desc = EVTDESC37003
	picture = GFX_evt_bad_news
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA37003 # This will not stand!
		opinion = { who = FROM modifier = opinion_denied_title months = 60 }
		set_character_flag = flag_denied_title
	}
}

# The relative is disappointed
character_event = {
	id = 37004
	desc = EVTDESC37004
	picture = GFX_evt_bad_news
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA37004 # I'll ask again later...
		trigger = { NOT = { has_character_flag = flag_later_title } }
		set_character_flag = flag_later_title
	}
	
	option = {
		name = EVTOPTB37004 # Not again!
		trigger = { has_character_flag = flag_later_title }
		ai_chance = { factor = 750 }
		opinion = { who = FROM modifier = opinion_denied_title months = 120 }
		clr_character_flag = flag_later_title
		set_character_flag = flag_denied_title
	}
	
	option = {
		name = EVTOPTB37007
		trigger = {
			has_character_flag = flag_later_title
			NOT = { trait = content }
			NOT = { trait = patient }
			NOT = { trait = craven }
			NOT = { age = 65 }
			liege = { independent = yes }
		}
		
		ai_chance = {
			factor = 100
			modifier = {
				factor = 2.5
				trait = ambitious
			}
			modifier = {
				factor = 0.25
				trait = carefree
			}
		}
		
		opinion = {
			who = FROM
			modifier = opinion_broken_title_promise
			months = 120
		}
		clr_character_flag = flag_promised_title
		remove_character_modifier = promised_a_title
		set_character_flag = flag_denied_title
		
		character_event = { id = 37010 days = 45 }
	}
}

# Relative reminds liege of promised title
character_event = {
	id = 37005
	desc = EVTDESC37005
	picture = GFX_evt_son_asking_father
	
	is_triggered_only = yes
	
	trigger = {
		independent = no
		is_ruler = no
		prisoner = no
		NOT = { trait = incapable }
		has_ambition = obj_become_ruler
		has_character_flag = flag_promised_title
		liege = {
			any_demesne_title = {
				can_be_given_away = yes
				AND = {
					tier = count
					holding_type = castle
					location = {
						is_capital = no
					}				
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA37005 # Ask liege for a title
		liege = { character_event = { id = 37006 tooltip = EVTTOOLTIP37006 } }
	}
}

# Liege responds to the reminder
character_event = {
	id = 37006
	desc = EVTDESC37006
	picture = GFX_evt_son_asking_father
	
	is_triggered_only = yes
	
	trigger = { FROM = { is_alive = yes } }
	
	option = {
		trigger = {
			OR = {
				AND = {
					OR = {
						government = military_monarchy
						government = pirate_kingdom
					}
					any_demesne_title = {
						can_be_given_away = yes
						tier = count
						holding_type = castle
						location = { is_capital = no }
					}
				}
				AND = {
					government = corporate_monarchy
					any_demesne_title = {
						can_be_given_away = yes
						tier = count
						holding_type = city
						location = { is_capital = no }
					}
				}
				AND = {
					government = administrative_monarchy
					any_demesne_title = {
						can_be_given_away = yes
						tier = count
						holding_type = temple
						location = { is_capital = no }
					}
				}
			}
		}
		name = EVTOPTA37006 # Oh, very well!
		if = {
			limit = {
				OR = {
					government = pirate_kingdom
					government = military_monarchy
				}
			}
			random_demesne_title = {
				limit = {
					can_be_given_away = yes
					tier = count
					holding_type = castle
					location = { is_capital = no }
				}
				grant_title = FROM
			}
		}
		if = {
			limit = { government = corporate_monarchy }
			random_demesne_title = {
				limit = {
					can_be_given_away = yes
					tier = count
					holding_type = city
					location = { is_capital = no }
				}
				grant_title = FROM
			}
		}
		if = {
			limit = { government = administrative_monarchy }
			random_demesne_title = {
				limit = {
					can_be_given_away = yes
					tier = count
					holding_type = temple
					location = { is_capital = no }
				}
				grant_title = FROM
			}
		}
		ai_chance = {
			factor = 75
			modifier = {
				factor = 2
				trait = friendly
			}
			modifier = {
				factor = 0.5
				trait = cold
			}
			modifier = {
				factor = 2
				trait = radical
			}
			modifier = {
				factor = 0.5
				trait = pragmatic
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 100 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 90 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 80 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 70 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 60 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 50 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 40 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 30 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 20 }
			}
			modifier = {
				factor = 1.25
				opinion = { who = FROM value = 10 }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -9 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -19 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -29 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -39 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -49 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -59 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -69 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -79 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -89 } }
			}
			modifier = {
				factor = 0.8
				NOT = { opinion = { who = FROM value = -99 } }
			}
		}
	}
	
	option = {
		name = EVTOPTB37006 # I've had it with his whining!
		FROM = { character_event = { id = 37007 days = 2 tooltip = EVTTOOLTIP37007 } }
		
		if = {
			limit = {
				ai = no
				independent = yes
				FROM = {
					NOT = { trait = content }
					NOT = { trait = patient }
					NOT = { trait = craven }
					NOT = { age = 65 }
				}
			}
			custom_tooltip = { text = evt_relative_might_revolt }
		}
		ai_chance = { factor = 25 }
	}
}

# Liege breaks the promise
character_event = {
	id = 37007
	desc = EVTDESC37007
	picture = GFX_evt_bad_news
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA37007 # This is an outrage!
		ai_chance = { factor = 500 }
		
		opinion = { who = FROM modifier = opinion_broken_title_promise months = 120 }
		clr_character_flag = flag_promised_title
		remove_character_modifier = promised_a_title
		set_character_flag = flag_denied_title
	}
	option = {
		name = EVTOPTB37007 # I will not stand for this! REVOLT!
		
		trigger = {
			NOT = { trait = content }
			NOT = { trait = patient }
			NOT = { trait = craven }
			NOT = { age = 65 }
			liege = {
				independent = yes
			}
		}
		
		ai_chance = {
			factor = 100
			modifier = {
				factor = 2.5
				trait = ambitious
			}
			modifier = {
				factor = 0.25
				trait = carefree
			}
		}
		
		opinion = { who = FROM modifier = opinion_broken_title_promise months = 120 }
		clr_character_flag = flag_promised_title
		remove_character_modifier = promised_a_title
		set_character_flag = flag_denied_title
		
		character_event = { id = 37010 days = 45 }
	}
}

# Character goes into exile to raise an army
character_event = {
	id = 37010
	
	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		independent = no
		is_ruler = no
		prisoner = no
		NOT = { trait = incapable }
		FROMFROM = {
			is_alive = yes
			independent = yes
		}
		
		liege = {
			capital_scope = {
				any_independent_ruler = {
					religion_group = ROOT
					is_landed = yes
					NOT = { character = PREVPREV }
					capital_scope = {
						NOT = {
							distance = {
								where = PREVPREV
								distance = 400
							}
						}
					}
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA37010
		liege = {
			capital_scope = {
				random_independent_ruler = {
					limit = {
						religion_group = ROOT
						is_landed = yes
						NOT = { character = PREVPREV }
						capital_scope = {
							NOT = {
								distance = {
									where = PREVPREV
									distance = 400
								}
							}
						}
					}
					character_event = { id = 37011 } # Notify the new host
					ROOT = {
						move_character = PREV
					}
				}
			}
		}
	}
}

# The ruler who hosts the pretender is notified
character_event = {
	id = 37011
	desc = EVTDESC37011
	picture = GFX_evt_large_army
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA37011 # Interesting
		
		hidden_tooltip = {
			FROMFROMFROM = { character_event = { id = 37012 } } # Notify the old liege
		}
	}
}

# The old liege is notified
character_event = {
	id = 37012
	desc = EVTDESC37012
	picture = GFX_evt_large_army
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA37012 # The traitorous git!
		
		opinion = {
			who = FROMFROM
			modifier = opinion_traitor
		}
		
		hidden_tooltip = {
			opinion = {
				who = FROMFROM
				modifier = opinion_targeted_by_adventurer
				months = 12
			}
			FROMFROM = { character_event = { id = 37015 days = 365 } } # The event that actually fires the revolt
		}
	}
}

# The pretender launches the attack
character_event = {
	id = 37015
	
	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		independent = no
		is_ruler = no
		prisoner = no
		NOT = { trait = incapable }
		FROM = {
			is_alive = yes
			independent = yes
		}
		liege = {
			character = FROMFROM
		}
	}
	
	option = {
		name = OK
		
		liege = {
			capital_scope = {
				ROOT = {
					set_defacto_liege = ROOT
					create_title = {
						tier = DUKE
						landless = yes
						temporary = yes
						culture = ROOT
						name = "CLAIMANT_ADVENTURE"
						holder = ROOT
					}
				}
				FROM = {
					ROOT = {
						set_character_flag = claimant_adventurer
						random_list = {
							34 = {
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									leader = THIS
									match_character = PREV
									match_mult = 0.25
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.25
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.25
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.25
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.25
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.25
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
							}
							33 = {
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									leader = THIS
									match_character = PREV
									match_mult = 0.2
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.2
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.2
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.2
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.2
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.2
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
							}
							33 = {
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									leader = THIS
									match_character = PREV
									match_mult = 0.15
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.15
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.15
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.15
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.15
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
								spawn_unit = {
									province = PREVPREV
									home = PREVPREV
									owner = THIS
									match_character = PREV
									match_mult = 0.15
									match_min = 300
									match_max = 5000
									attrition = 0.25
									earmark = claimant_adventure
									disband_on_peace = yes
								}
							}
						}
					}
				}
			}
		}
		
		# Create some decent commander characters
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 30
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 25
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 33
		}
		create_random_soldier = {
			random_traits = yes
			dynasty = none
			religion = ROOT
			culture = ROOT
			female = no
			age = 29
		}
		
		# Create a fleet, just to be sure
		spawn_fleet = {
			province = closest # closest sea zone
			owner = ROOT
			disband_on_peace = yes
			troops =
			{
				galleys = { 150 150 }
			}
			earmark = claimant_adventure
		}
		
		FROM = {
			# Prioritize going for secondary empires
			if = {
				limit = {
					num_of_emperor_titles = 2
				}
				random_demesne_title = {
					limit = {
						tier = EMPEROR
						is_primary_holder_title = no
					}
					ROOT = {
						add_claim = PREV
					}
					holder_scope = {
						reverse_war = {
							target = ROOT
							casus_belli = claim
							thirdparty_title = PREV
						}
					}
				}
			}
			
			# Next, secondary kingdoms
			if = {
				limit = {
					num_of_king_titles = 2
					NOT = { war_with = ROOT }
				}
				random_demesne_title = {
					limit = {
						tier = KING
						is_primary_holder_title = no
					}
					ROOT = {
						add_claim = PREV
					}
					holder_scope = {
						reverse_war = {
							target = ROOT
							casus_belli = claim
							thirdparty_title = PREV
						}
					}
				}
			}
		
			# Otherwise, just go for the primary title
			if = {
				limit = {
					NOT = { war_with = ROOT }
				}
				primary_title = {
					ROOT = {
						add_claim = PREV
					}
					holder_scope = {
						reverse_war = {
							target = ROOT
							casus_belli = claim
							thirdparty_title = PREV
						}
					}
				}
			}
		}
	}
}

# IDs to 37049 reserved for more events concerning this ambition

# IDs to 37149 reserved for more events concerning this ambition