###################################
#
# Events for Rivals
#
# Id 10000-10999 is reserved
#
###################################
#
# Written by Sara Wendel-Örtqvist

#Start - two neighbouring clan leaders hate each other
character_event = {
	id = 10000
	desc = "EVTDESC10000"
	
	trigger = {
		independent = yes
		is_ruler = yes
		any_independent_neighbor = {
			relative_power = { 
				who = ROOT
				value = 0.25
			}
			NOT = {
				has_opinion_modifier = { who = ROOT modifier = opinion_rival }
			}
			OR = {
				NOT = {
					opinion = {	who = ROOT value = 20 }
				}
				NOT = {
					their_opinion = {	who = ROOT value = 20 }
				}
			}
			NOT = {
				has_character_modifier = has_rival_timer
			}
		}
		NOT = {
			has_character_modifier = has_rival_timer
		}
	}
	
	mean_time_to_happen = {
		months = 480
		
		modifier = {
			factor = 0.5
			trait = wroth
		}
		
		modifier = {
			factor = 2
			trait = trusting
		}
	}
	
	option = {
		name = "EVTOPTA10000"
		ai_chance = { factor = 75 }
		hidden_tooltip = {
			add_character_modifier = {
				name = has_rival_timer
				duration = 1095
			}
		}
		random_independent_neighbor = {
			limit = {
				NOT = {
					has_opinion_modifier = { who = ROOT modifier = opinion_rival }
				}
				OR = {
					NOT = {
						opinion = {	who = ROOT value = 20 }
					}
					NOT = {
						their_opinion = {	who = ROOT value = 20 }
					}
				}
			}
			reverse_opinion = {
				modifier = opinion_rival
				who = ROOT
				years = 10
			}
			character_event = {
				id = 10001
				tooltip = "EVTTOOLTIP10001"
			}
			hidden_tooltip = {
				add_character_modifier = {
					name = has_rival_timer
					duration = 1095
				}
			}
		}
	}
	option = {
		name = "EVTOPTB10000"
		honor = -5
	}
}

#Independent Neighbour
character_event = {
	id = 10001
	desc = "EVTDESC10001"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA10001"
		FROM = {
			reverse_opinion = {
				modifier = opinion_rival
				who = ROOT
				years = 10
			}
		}
	}
}

# The hate spreads...
character_event = {
	id = 10002
	desc = "EVTDESC10002"
	
	trigger = {
		has_character_modifier = has_rival_timer
		any_independent_neighbor = {
			is_plot_target_of = ROOT
			has_opinion_modifier = { who = ROOT modifier = opinion_rival }
			has_character_modifier = has_rival_timer
		}
		any_independent_neighbor = {
			NOT = {
				is_plot_target_of = ROOT
			}
			NOT = {
				has_opinion_modifier = { who = ROOT modifier = opinion_rival }
			}
			NOT = {
				has_character_modifier = has_rival_timer
			}
		}
	}
	
	mean_time_to_happen = {
		months = 240
	}
	
	option = {
		name = "EVTOPTA10002"
		random_independent_neighbor = {
			limit = {
				ROOT = {
					plot_target = {
						character = PREV
					}
				}
				has_opinion_modifier = { who = ROOT modifier = opinion_rival }
			}
			set_character_flag = rival_nemesis
		}
		random_independent_neighbor = {
			limit = {
				NOT = {
					ROOT = {
						plot_target = {
							character = PREV
						}
					}
				}
				NOT = {
					has_opinion_modifier = { who = ROOT modifier = opinion_rival }
				}
			}
			character_event = {
				id = 10003
				tooltip = "EVTTOOLTIP10003"
			}
		}
	}
	option = {
		name = "EVTOPTB10002"
		honor = -5
	}
}

#Ind. neighbour reacts
character_event = {
	id = 10003
	desc = "EVTDESC10003"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA10003"
		random_independent_neighbor = {
			limit = {
				has_character_flag = rival_nemesis
			}
			reverse_opinion = {
				modifier = opinion_rival
				who = ROOT
				years = 10
			}
			clr_character_flag = rival_nemesis
		}
		FROM = {
			set_character_flag = common_enemy
			character_event = {
				id = 10004
				tooltip = "EVTTOOLTIP10004"
			}
		}
	}
	option = {
		name = "EVTOPTB10003"
		FROM = {
			reverse_opinion = {
				modifier = opinion_rival
				who = ROOT
				years = 10
			}
			set_character_flag = nemesis_nemesis
			character_event = {
				id = 10004
				tooltip = "EVTTOOLTIP10004"
			}
		}
	}
	option = {
		name = "EVTOPTC10003"
		honor = -5
		FROM = {
			set_character_flag = ignore_rival
			character_event = {
				id = 10004
				tooltip = "EVTTOOLTIP10004"
			}
		}
	}
}

#Answer from Ind. clan leader
character_event = {
	id = 10004
	desc = "EVTDESC10004"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA10004"
		trigger = {
			has_character_flag = common_enemy
		}
		clr_character_flag = common_enemy
		FROM = {
			reverse_opinion = {
				modifier = opinion_ally
				who = ROOT
				years = 1
			}
		}
	}
	option = {
		name = "EVTOPTB10004"
		trigger = {
			has_character_flag = nemesis_nemesis
		}
		clr_character_flag = nemesis_nemesis
		FROM = {
			reverse_opinion = {
				modifier = opinion_rival
				who = ROOT
				years = 10
			}
		}
	}
	option = {
		name = "EVTOPTC10004"
		trigger = {
			has_character_flag = ignore_rival
		}
		clr_character_flag = ignore_rival
		FROM = {
			reverse_opinion = {
				modifier = opinion_disappointed #TODO: CREATE!
				who = ROOT
				years = 10
			}
		}
	}
}

#-Relation
character_event = {
	id = 10005
	desc = "EVTDESC10005"
	
	trigger = {
		ai = no
		independent = yes
		any_independent_neighbor = {
			has_opinion_modifier = { who = ROOT modifier = opinion_rival }
			NOT = {
				character = ROOT
			}
			NOT = {
				war_with = ROOT
			}
		}
		NOT = {
			has_character_modifier = minus_relation_rival_timer
		}
	}
	
	mean_time_to_happen = {
		months = 360
		
		modifier = {
			factor = 0.5
			trait = wroth
		}
		
		modifier = {
			factor = 2
			trait = content
		}
	}
	
	immediate = {
		hidden_tooltip = {
			add_character_modifier = {
				name = minus_relation_rival_timer
				duration = 365
			}
		}
	}
	
	option = {
		name = "EVTOPTA10005"
		random_independent_neighbor = {
			limit = {
				has_opinion_modifier = { who = ROOT modifier = opinion_rival }
				NOT = {
					character = ROOT
				}
				NOT = {
					war_with = ROOT
				}
			}
			reverse_opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 1
			}
		}
	}
	option = {
		name = "EVTOPTB10005"
		honor = -5
	}
}

#-Relation
character_event = {
	id = 10006
	desc = "EVTDESC10006"
	
	trigger = {
		independent = yes
		any_independent_neighbor = {
			has_opinion_modifier = { who = ROOT modifier = opinion_rival }
			NOT = {
				character = ROOT
			}
			NOT = {
				war_with = ROOT
			}
		}
		NOT = {
			has_character_modifier = minus_relation_rival_timer
		}
	}
	
	mean_time_to_happen = {
		months = 360
		
		modifier = {
			factor = 0.5
			trait = deceitful
		}
		
		modifier = {
			factor = 2
			trait = kind
		}
	}
	
	immediate = {
		hidden_tooltip = {
			add_character_modifier = {
				name = minus_relation_rival_timer
				duration = 365
			}
		}
	}
	
	option = {
		name = "EVTOPTA10006"
		random_independent_neighbor = {
			limit = {
				has_opinion_modifier = { who = ROOT modifier = opinion_rival }
				NOT = {
					character = ROOT
				}
				NOT = {
					war_with = ROOT
				}
			}
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 1
			}
		}
	}
}

#-Relation
character_event = {
	id = 10007
	desc = "EVTDESC10007"
	
	trigger = {
		independent = yes
		any_independent_neighbor = {
			has_opinion_modifier = { who = ROOT modifier = opinion_rival }
			NOT = {
				character = ROOT
			}			
			NOT = {
				war_with = ROOT
			}
		}
		NOT = {
			has_character_modifier = minus_relation_rival_timer
		}
	}
	
	mean_time_to_happen = {
		months = 360
		
		modifier = {
			factor = 0.5
			trait = envious
		}
		
		modifier = {
			factor = 2
			trait = patient
		}
	}
	
	immediate = {
		hidden_tooltip = {
			add_character_modifier = {
				name = minus_relation_rival_timer
				duration = 365
			}
		}
	}
	
	option = {
		name = "EVTOPTA10007"
		random_independent_neighbor = {
			limit = {
				has_opinion_modifier = { who = ROOT modifier = opinion_rival }
				NOT = {
					character = ROOT
				}
				NOT = {
					war_with = ROOT
				}
			}
			reverse_opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 1
			}
		}
	}
	option = {
		name = "EVTOPTB10007"
		honor = -5
	}
}

#+Relation
character_event = {
	id = 10008
	desc = "EVTDESC10008"
	
	trigger = {
		independent = yes
		any_independent_neighbor = {
			has_opinion_modifier = { who = ROOT modifier = opinion_rival }
			NOT = {
				character = ROOT
			}
			NOT = {
				war_with = ROOT
			}
		}
		NOT = {
			has_character_modifier = plus_relation_rival_timer
		}
	}
	
	mean_time_to_happen = {
		months = 480
		
		modifier = {
			factor = 0.5
			trait = charitable
		}
		
		modifier = {
			factor = 2
			trait = wroth
		}
	}
	
	immediate = {
		hidden_tooltip = {
			add_character_modifier = {
				name = plus_relation_rival_timer
				duration = 365
			}
		}
	}
	
	option = {
		name = "EVTOPTA10008"
		random_independent_neighbor = {
			limit = {
				has_opinion_modifier = { who = ROOT modifier = opinion_rival }
				NOT = {
					character = ROOT
				}
				NOT = {
					war_with = ROOT
				}
			}
			reverse_opinion = {
				modifier = opinion_forgiven
				who = ROOT
				years = 1
			}
		}
	}
	
	option = {
		name = "EVTOPTB10008"
		honor = -5
	}
}

#+Relation
character_event = {
	id = 10009
	desc = "EVTDESC10009"
	
	trigger = {
		independent = yes
		any_independent_neighbor = {
			has_opinion_modifier = { who = ROOT modifier = opinion_rival }
			NOT = {
				character = ROOT
			}
			NOT = {
				war_with = ROOT
			}
		}
		NOT = {
			has_character_modifier = plus_relation_rival_timer
		}
	}
	
	mean_time_to_happen = {
		months = 480
		
		modifier = {
			factor = 0.5
			trait = kind
		}
		
		modifier = {
			factor = 2
			trait = craven
		}
	}
	
	immediate = {
		hidden_tooltip = {
			add_character_modifier = {
				name = plus_relation_rival_timer
				duration = 365
			}
		}
	}
	
	option = {
		name = "EVTOPTA10009"
		random_independent_neighbor = {
			limit = {
				has_opinion_modifier = { who = ROOT modifier = opinion_rival }
				NOT = {
					character = ROOT
				}
				NOT = {
					war_with = ROOT
				}
			}
			opinion = {
				modifier = opinion_forgiven
				who = ROOT
				years = 1
			}
			reverse_opinion = {
				modifier = opinion_forgiven
				who = ROOT
				years = 1
			}
		}
	}
	option = {
		name = "EVTOPTB10009"
		honor = -5
	}
}

#+Relation
character_event = {
	id = 10010
	desc = "EVTDESC10010"
	
	trigger = {
		independent = yes
		any_independent_neighbor = {
			has_opinion_modifier = { who = ROOT modifier = opinion_rival }
			NOT = {
				character = ROOT
			}
			NOT = {
				war_with = ROOT
			}
		}
		NOT = {
			has_character_modifier = plus_relation_rival_timer
		}
	}
	
	mean_time_to_happen = {
		months = 480
		
		modifier = {
			factor = 0.5
			trait = kind
		}
		
		modifier = {
			factor = 2
			trait = craven
		}
	}
	
	immediate = {
		hidden_tooltip = {
			add_character_modifier = {
				name = plus_relation_rival_timer
				duration = 365
			}
		}
	}
	
	option = {
		name = "EVTOPTA10010"
		random_independent_neighbor = {
			limit = {
				has_opinion_modifier = { who = ROOT modifier = opinion_rival }
				NOT = {
					character = ROOT
				}
				NOT = {
					war_with = ROOT
				}
			}
			reverse_opinion = {
				modifier = opinion_forgiven
				who = ROOT
				years = 1
			}
			opinion = {
				modifier = opinion_forgiven
				who = ROOT
				years = 1
			}
		}
	}
	option = {
		name = "EVTOPTB10010"
		honor = -5
	}
}

#Vassal dislikes liege
character_event = {
	id = 10015
	desc = "EVTDESC10015"
	
	trigger = {
		independent = yes
		treasury = 25
		any_direct_vassal = {
			is_primary_heir = no
			NOT = {
				opinion = { who = ROOT value = -10 }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 150
		
		modifier = {
			factor = 0.5
			trait = deceitful
		}
		
		modifier = {
			factor = 2
			trait = content
		}
	}
	
	option = {
		name = "EVTOPTA10015"
		random_direct_vassal = {
			limit = {
				is_primary_heir = no
				NOT = {
					opinion = { who = ROOT value = -10 }
				}
			}
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 5
			}
		}		
	}
	option = {
		name = "EVTOPTB10015"
		treasury = -25
		random_direct_vassal = {
			limit = {
				is_primary_heir = no
				NOT = {
					opinion = { who = ROOT value = -10 }
				}
			}
			treasury = 25
			opinion = {
				modifier = opinion_forgiven
				who = ROOT
				years = 5
			}
		}		
	}
}

#Vassal start disliking liege
character_event = {
	id = 10016
	desc = "EVTDESC10016"
	
	trigger = {
		independent = no
		is_ruler = yes
		liege = {
			NOT = {
				character = ROOT
			}
			independent = yes
			ROOT = {
				is_primary_heir = no
			}
		}
	}
	
	mean_time_to_happen = {
		months = 150
		
		modifier = {
			factor = 0.5
			trait = ambitious
		}
		
		modifier = {
			factor = 2
			trait = honest
		}
	}
	
	option = {
		name = "EVTOPTA10016"
		liege = {
			reverse_opinion = {
				modifier = opinion_insulted
				who = ROOT
				years = 2
			}
		}
	}
	
	option = {
		name = "EVTOPTB10016"
		honor = -5
	}
}

#Vassal start disliking liege
character_event = {
	id = 10017
	desc = "EVTDESC10017"
	
	trigger = {
		is_ruler = yes
		liege = {
			independent = yes
			NOT = {
				character = ROOT
			}
			NOT = {
				honor = 20
			}
			ROOT = {
				is_primary_heir = no
			}
		}
	}
	
	mean_time_to_happen = {
		months = 150
		
		modifier = {
			factor = 0.5
			trait = ambitious
		}
		
		modifier = {
			factor = 2
			trait = honest
		}
	}
	
	option = {
		name = "EVTOPTA10017"
		liege = {
			reverse_opinion = {
				modifier = opinion_disgusted
				who = ROOT
				years = 3
			}
		}
	}
	option = {
		name = "EVTOPTB10017"
		honor = -5
	}
}

#What to do?
character_event = {
	id = 10018
	desc = "EVTDESC10018"
	
	trigger = {
		is_ruler = yes
		liege = {
			independent = yes
			NOT = {
				character = ROOT
			}
			ROOT = {
				is_primary_heir = no
			}
			father = {	
				NOT = {
					character = ROOT
				}
			}
			NOT = {
				their_opinion = { who = ROOT value = -50 }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 3000
		
	}
	
	option = {
		name = "EVTOPTA10018"
		liege = {
			character_event = {
				id = 10019
				tooltip = "EVTTOOLTIP10019"
			}
			opinion = {
				modifier = opinion_forgiven
				who = ROOT
				years = 2
			}
		}
	}
	option = {
		name = "EVTOPTB10018"
		liege = {
			character_event = {
				id = 10020
				tooltip = "EVTTOOLTIP10020"
			}
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 2
			}
		}
	}
}

#Liege reacts to positive relations
character_event = {
	id = 10019
	desc = "EVTDESC10019"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA10019"
		FROM = {
			opinion = {
				modifier = opinion_relieved
				who = ROOT
				years = 2
			}
		}	
	}
}

#Liege reacts to negative relations
character_event = {
	id = 10020
	desc = "EVTDESC10020"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA10020"
		FROM = {
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 2
			}
		}	
	}
}

#Vassal start disliking liege
character_event = {
	id = 10021
	desc = "EVTDESC10021"
	
	trigger = {
		is_ruler = yes
		liege = {
			independent = yes
			NOT = {
				character = ROOT
			}
			OR = {
				trait = lunatic
				trait = drunkard
			}
			ROOT = {
				is_primary_heir = no
			}
		}
	}
	
	mean_time_to_happen = {
		months = 150
		
		modifier = {
			factor = 0.5
			trait = ambitious
		}
		
		modifier = {
			factor = 2
			trait = honest
		}
	}
	
	option = {
		name = "EVTOPTA10021"
		liege = {
			reverse_opinion = {
				modifier = opinion_disgusted
				who = ROOT
				years = 3
			}
		}
	}
	option = {
		name = "EVTOPTB10021"
		honor = -5
	}
}

#Remove Rival
character_event = {
	id = 10025
	desc = "EVTDESC10025"
	
	trigger = {
		ai = no
		independent = yes
		any_independent_neighbor = {
			NOT = {
				relative_power = { 
					who = ROOT
					value = 0.15
				}
			}
			has_opinion_modifier = { who = ROOT modifier = opinion_rival }
			NOT = {
				character = ROOT
			}
			NOT = {
				war_with = ROOT
			}
		}
	}
	
	mean_time_to_happen = {
		months = 360
		
		modifier = {
			factor = 0.5
			trait = kind
		}
		
		modifier = {
			factor = 2
			trait = envious
		}
	}
	
	option = {
		name = "EVTOPTA10025"
		random_independent_neighbor = {
			limit = {
				has_opinion_modifier = { who = ROOT modifier = opinion_rival }
				NOT = {
					character = ROOT
				}
				NOT = {
					war_with = ROOT
				}
			}
			remove_opinion = {
				who = ROOT
				modifier = opinion_rival
			}
			character_event = {
				id = 10026
				tooltip = "EVTTOOLTIP10026"
			}
		}
	}
}

#Rival loses opinion_rival
character_event = {
	id = 10026
	desc = "EVTDESC10026"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA10026"
		FROM = {
			remove_opinion = {
				modifier = opinion_rival
				who = ROOT
			}
		}
		random = {
			chance = 5
			add_trait = depressed
		}
	}
}