###########################################
#
# Campaign Events
#
# ID 6900-6999 is reserved
#
###########################################
#
# Written by Johan Andersson

# Become friendly with a fellow vassal when both at same location and we got same liege
character_event = {
	id = 6900
	desc = EVTDESC6900
	picture = GFX_evt_battle

	is_triggered_only = yes # on_unit_entering_province, random_events, campaign_events

	only_rulers = yes

	trigger = {
		in_command_trigger = yes
		independent = no
		NOT = { trait = shy }

		liege = {
			any_vassal = {
				at_location = ROOT
				in_command_trigger = yes

				opinion = {
					who = ROOT
					value >= -30
				}

				opinion = {
					who = ROOT
					value < 30
				}

				NOR = {
					trait = shy
					war_with = ROOT
					character = ROOT
				}
			}
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 1.25
			trait = gregarious
		}

		mult_modifier = {
			factor = 1.25
			trait = brave
		}
	}

	immediate = {
		liege = {
			random_vassal = {
				limit = {
					at_location = ROOT
					in_command_trigger = yes

					opinion = {
						who = ROOT
						value >= -30
					}

					opinion = {
						who = ROOT
						value < 30
					}

					NOR = {
						trait = shy
						war_with = ROOT
						character = ROOT
					}
				}

				save_event_target_as = campaign_friend_6900
			}
		}
	}

	option = {
		name = EVTOPTA6900

		event_target:campaign_friend_6900 = {
			show_scope_change = no

			add_friend = ROOT

			opinion = {
				name = campaign_friend
				who = ROOT
				years = 10
			}

			character_event = {
				id = 6901
				days = 1
			}
		}
	}
}

# Brother in arms!
character_event = {
	id = 6901
	desc = EVTDESC6901
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA6901

		tooltip = {
			add_friend = FROM

			reverse_opinion = {
				name = campaign_friend
				who = FROM
				years = 10
			}
		}
	}
}

# Save someone's life at the battlefield...  become very good friend.
character_event = {
	id = 6910
	desc = EVTDESC6910
	picture = GFX_evt_battle

	is_triggered_only = yes # on_battle, random_events via HFP.11000

	immediate = {
		liege = {
			random_vassal = {
				limit = {
					at_location = ROOT
					in_command_trigger = yes
					in_battle = yes
					health_traits < 1

					opinion = {
						who = ROOT
						value >= -30
					}

					opinion = {
						who = ROOT
						value < 30
					}

					NOR = {
						war_with = ROOT
						character = ROOT
					}
				}

				save_event_target_as = campaign_friend_6910
			}
		}
	}

	option = {
		name = EVTOPTA6910

		event_target:campaign_friend_6910 = {
			show_scope_change = no

			prestige = 5
			add_friend = ROOT

			if = {
				limit = { has_dlc = "Conclave" }
				reverse_add_favor = ROOT
			}

			character_event = {
				id = 6911
				days = 1
			}
		}
	}
}

# Saved a new friend
character_event = {
	id = 6911
	desc = EVTDESC6911
	picture = GFX_evt_battle

	is_triggered_only = yes

	option = {
		name = EVTOPTA6911

		add_trait = wounded

		tooltip = {
			add_friend = FROM

			if = {
				limit = { has_dlc = "Conclave" }
				reverse_add_favor = FROM
			}
		}
	}
}

# Become rival with a fellow vassal when both at same location and we got same liege
character_event = {
	id = 6920
	desc = EVTDESC6920
	picture = GFX_evt_battle

	is_triggered_only = yes # on_unit_entering_province, random_events, campaign_events

	only_rulers = yes

	trigger = {
		independent = no

		liege = {
			any_vassal = {
				at_location = ROOT
				in_command_trigger = yes

				opinion = {
					who = ROOT
					value >= -30
				}

				opinion = {
					who = ROOT
					value < 30
				}

				NOR = {
					war_with = ROOT
					character = ROOT
				}
			}
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 1.25
			trait = deceitful
		}

		mult_modifier = {
			factor = 1.25
			trait = wroth
		}
	}

	immediate = {
		liege = {
			random_vassal = {
				limit = {
					at_location = ROOT
					in_command_trigger = yes

					opinion = {
						who = ROOT
						value >= -30
					}

					opinion = {
						who = ROOT
						value < 30
					}

					NOR = {
						war_with = ROOT
						character = ROOT
					}
				}

				save_event_target_as = campaign_friend_6920
			}
		}
	}

	option = {
		name = EVTOPTA6920

		event_target:campaign_friend_6920 = {
			show_scope_change = no

			add_rival = ROOT

			opinion = {
				name = campaign_rival
				who = ROOT
				years = 5
			}

			character_event = {
				id = 6921
				days = 1
			}
		}
	}
}

# Gained a rival
character_event = {
	id = 6921
	desc = EVTDESC6921
	picture = GFX_evt_battle

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA6921

		tooltip = {
			add_rival = FROM

			reverse_opinion = {
				name = campaign_rival
				who = FROM
				years = 5
			}
		}
	}
}